Browse code

pv: added kemi functions to test if xavp is null

Daniel-Constantin Mierla authored on 06/06/2019 09:33:14
Showing 1 changed files
... ...
@@ -1064,6 +1064,23 @@ static int w_xavp_rm_child(sip_msg_t *msg, char *prname, char *pcname)
1064 1064
 /**
1065 1065
  *
1066 1066
  */
1067
+static int ki_xavp_is_null(sip_msg_t *msg, str *rname)
1068
+{
1069
+	sr_xavp_t *xavp=NULL;
1070
+
1071
+	xavp = xavp_get_by_index(rname, 0, NULL);
1072
+	if(xavp==NULL) {
1073
+		return 1;
1074
+	}
1075
+	if(xavp->val.type == SR_XTYPE_NULL) {
1076
+		return 1;
1077
+	}
1078
+	return -1;
1079
+}
1080
+
1081
+/**
1082
+ *
1083
+ */
1067 1084
 static sr_kemi_xval_t _sr_kemi_pv_xval = {0};
1068 1085
 
1069 1086
 /**
... ...
@@ -1174,6 +1191,30 @@ static sr_kemi_xval_t* ki_xavp_getw(sip_msg_t *msg, str *rname)
1174 1174
 /**
1175 1175
  *
1176 1176
  */
1177
+static int ki_xavp_child_is_null(sip_msg_t *msg, str *rname, str *cname)
1178
+{
1179
+	sr_xavp_t *xavp=NULL;
1180
+
1181
+	xavp = xavp_get_by_index(rname, 0, NULL);
1182
+	if(xavp==NULL) {
1183
+		return 1;
1184
+	}
1185
+	if(xavp->val.type != SR_XTYPE_XAVP) {
1186
+		return 1;
1187
+	}
1188
+	xavp = xavp_get_by_index(cname, 0, &xavp->val.v.xavp);
1189
+	if(xavp==NULL) {
1190
+		return 1;
1191
+	}
1192
+	if(xavp->val.type == SR_XTYPE_NULL) {
1193
+		return 1;
1194
+	}
1195
+	return -1;
1196
+}
1197
+
1198
+/**
1199
+ *
1200
+ */
1177 1201
 static sr_kemi_xval_t* ki_xavp_get_child_mode(sip_msg_t *msg, str *rname,
1178 1202
 		str *cname, int rmode)
1179 1203
 {
... ...
@@ -1637,11 +1678,21 @@ static sr_kemi_t sr_kemi_pvx_exports[] = {
1637 1637
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1638 1638
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1639 1639
 	},
1640
+	{ str_init("pvx"), str_init("xavp_is_null"),
1641
+		SR_KEMIP_INT, ki_xavp_is_null,
1642
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1643
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1644
+	},
1640 1645
 	{ str_init("pvx"), str_init("xavp_rm_child"),
1641 1646
 		SR_KEMIP_INT, ki_xavp_rm_child,
1642 1647
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
1643 1648
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1644 1649
 	},
1650
+	{ str_init("pvx"), str_init("xavp_child_is_null"),
1651
+		SR_KEMIP_INT, ki_xavp_child_is_null,
1652
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
1653
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1654
+	},
1645 1655
 	{ str_init("pvx"), str_init("xavp_get"),
1646 1656
 		SR_KEMIP_XVAL, ki_xavp_get,
1647 1657
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,