[Serdev] AVPOPS patch - dst_ip

Evan Borgström evan.borgstrom at ca.mci.com
Wed Jun 15 14:58:20 UTC 2005


Hey All,

	Here's a patch for the avpops module in the rel_0_9_0 tag that adds the 
ability to test for $dst_ip along with $src_ip. Feel free to commit it 
into CVS if there's interest in it from others.

-Evan
-------------- next part --------------
--- ser-0.9.3.orig/modules/avpops/avpops.c	2005-06-14 11:47:34.000000000 -0400
+++ ser-0.9.3/modules/avpops/avpops.c	2005-06-14 11:53:02.000000000 -0400
@@ -376,6 +376,7 @@
 			if ( (!strcasecmp( "from", s) && (flags|=AVPOPS_USE_FROM))
 				|| (!strcasecmp( "to", s) && (flags|=AVPOPS_USE_TO))
 				|| (!strcasecmp( "ruri", s) && (flags|=AVPOPS_USE_RURI))
+				|| (!strcasecmp( "dst_ip", s) && (flags|=AVPOPS_USE_DST_IP))
 				|| (!strcasecmp( "src_ip", s) && (flags|=AVPOPS_USE_SRC_IP)) )
 			{
 				ap = (struct fis_param*)pkg_malloc(sizeof(struct fis_param));
@@ -387,7 +388,7 @@
 				}
 				memset( ap, 0, sizeof(struct fis_param));
 				/* any falgs ? */
-				if ( p && !( (flags&AVPOPS_USE_SRC_IP)==0 && (
+				if ( p && !( (flags&(AVPOPS_USE_SRC_IP|AVPOPS_USE_DST_IP))==0 && (
 				(!strcasecmp("username",p) && (flags|=AVPOPS_FLAG_USER)) ||
 				(!strcasecmp("domain", p) && (flags|=AVPOPS_FLAG_DOMAIN)))) )
 				{
--- ser-0.9.3.orig/modules/avpops/avpops_impl.c	2005-06-14 11:47:34.000000000 -0400
+++ ser-0.9.3/modules/avpops/avpops_impl.c	2005-06-14 11:55:19.000000000 -0400
@@ -567,6 +567,15 @@
 			}
 			s_ip.len = strlen(s_ip.s);
 			avp_val.s = &s_ip;
+		} else if (src->flags&AVPOPS_USE_DST_IP) {
+			/* get data from dst ip */
+			if ( (s_ip.s=ip_addr2a( &msg->rcv.dst_ip ))==0)
+			{
+				LOG(L_ERR,"ERROR:avpops:write_avp: cannot get dst_ip\n");
+				goto error;
+			}
+			s_ip.len = strlen(s_ip.s);
+			avp_val.s = &s_ip;
 		} else {
 			/* get data from uri (from,to,ruri) */
 			if (src->flags&(AVPOPS_FLAG_USER|AVPOPS_FLAG_DOMAIN))
@@ -898,6 +907,15 @@
 				}
 				s_ip.len = strlen(s_ip.s);
 				ck_val.s = &s_ip;
+			} else if (val->flags&AVPOPS_USE_DST_IP) {
+				/* get value from dst ip */
+				if ( (s_ip.s=ip_addr2a( &msg->rcv.dst_ip ))==0)
+				{
+					LOG(L_ERR,"ERROR:avpops:check_avp: cannot get dst_ip\n");
+					goto error;
+				}
+				s_ip.len = strlen(s_ip.s);
+				ck_val.s = &s_ip;
 			} else {
 				/* get value from uri */
 				if ( (ck_val.s=get_source_uri(msg,val->flags))==0 )
--- ser-0.9.3.orig/modules/avpops/avpops_impl.h	2005-06-14 11:47:34.000000000 -0400
+++ ser-0.9.3/modules/avpops/avpops_impl.h	2005-06-14 11:55:26.000000000 -0400
@@ -64,6 +64,7 @@
 #define AVPOPS_USE_HDRREQ    (1<<10)
 #define AVPOPS_USE_HDRRPL    (1<<11)
 #define AVPOPS_USE_SRC_IP    (1<<12)
+#define AVPOPS_USE_DST_IP    (1<<13)
 
 /* flags about operation  16..23  */
 #define AVPOPS_OP_EQ        (1<<16)
--- ser-0.9.3.orig/modules/avpops/avpops_parse.c	2005-06-14 11:47:34.000000000 -0400
+++ ser-0.9.3/modules/avpops/avpops_parse.c	2005-06-14 11:53:30.000000000 -0400
@@ -383,7 +383,8 @@
 		if ( (strncasecmp(p,"ruri"  ,len)==0 && (flags|=AVPOPS_USE_RURI))
 		  || (strncasecmp(p,"from"  ,len)==0 && (flags|=AVPOPS_USE_FROM))
 		  || (strncasecmp(p,"to"    ,len)==0 && (flags|=AVPOPS_USE_TO))
-		  || (strncasecmp(p,"src_ip",len)==0 && (flags|=AVPOPS_USE_SRC_IP)))
+		  || (strncasecmp(p,"src_ip",len)==0 && (flags|=AVPOPS_USE_SRC_IP))
+		  || (strncasecmp(p,"dst_ip",len)==0 && (flags|=AVPOPS_USE_DST_IP)))
 		{
 			flags |= AVPOPS_VAL_NONE;
 		} else {


More information about the Serdev mailing list