[prev in list] [next in list] [prev in thread] [next in thread] 

List:       serdev
Subject:    [Serdev] intra domain check
From:       mypop3mail () yahoo ! com (Richard)
Date:       2004-04-30 19:37:39
Message-ID: 20040430173906.15648.qmail () web20101 ! mail ! yahoo ! com
[Download RAW message or body]

Hi Daniel,

Thanks for your instruction. Here are the results of
the following command,
diff -u -r domain.old domain >domain.patch

Thanks,
Richard

--- Daniel-Constantin Mierla <daniel@iptel.org> wrote:
> you have to use -u option to diff ('diff -u old_file
> new_file' or better 
> 'diff -u -r old_module_dir new_module_dir') in order
> to generate a 
> proper patch.
> 
> Daniel
> 
> On 4/30/2004 11:25 AM, Richard wrote:
> 
> >Ok, I wrote the code. Haven't done coding for a
> while,
> >a bit rusty... but it seems to be working...
> >
> >I attached the code and copy here, just in case the
> >list doesn't allow attachment...
> >
> >Please let me know if the code is going to be
> added.
> >
> >[root@www domain]# diff domain.h domain.h.old
> >48,53d47
> >< /*
> ><  * Check if domains of from and request URI are
> same
> ><  */
> >< int is_intra_domain(struct sip_msg* _msg, char*
> _s1,
> >char* _s2);
> ><
> ><
> >[root@www domain]# diff domain.c domain.c.old
> >122,163d121
> ><
> >< /*
> ><  * Check if domains of from and request URI are
> same
> ><  */
> >< int is_intra_domain(struct sip_msg* _msg, char*
> _s1,
> >char* _s2) {
> ><       str uri;
> ><       struct sip_uri puri;
> ><
> ><       if (db_mode == 0) {
> ><               return 1;
> ><       }
> ><
> ><       if (parse_from_header(_msg) < 0) {
> ><               LOG(L_ERR, "is_from_local(): Error
> >while parsing From header\n");
> ><               return -2;
> ><       }
> ><
> ><       uri = get_from(_msg)->uri;
> ><
> ><       if (parse_uri(uri.s, uri.len, &puri) < 0) {
> ><               LOG(L_ERR, "is_from_local(): Error
> >while parsing URI\n");
> ><               return -3;
> ><       }
> ><
> ><       if (parse_sip_msg_uri(_msg) < 0) {
> ><           LOG(L_ERR, "is_uri_host_local(): Error
> >while parsing URI\n");
> ><           return -1;
> ><       }
> ><
> ><       if (puri.host.len !=
> >(_msg->parsed_uri.host).len) {
> ><                       LOG(L_ERR, "From and
> request
> >URI different length\n");
> ><                       return -1;
> ><       }
> ><
> ><       if (strncasecmp(puri.host.s,
> >_msg->parsed_uri.host.s, puri.host.len)==0) {
> ><               return 1;
> ><       } else {
> ><               return -1;
> ><       }
> >< }
> ><
> ><
> >[root@www domain]# diff domain_mod.c
> domain_mod.c.old
> >91d90
> ><       {"is_intra_domain", is_intra_domain, 0, 0,
> >REQUEST_ROUTE},
> >[root@www domain]#
> >
> >
> >--- Richard <mypop3mail@yahoo.com> wrote:
> >  
> >
> >>Sure, I can write the code. I guess the question
> is
> >>if
> >>the maintainer and the list think about the
> >>usefulness
> >>of this function. 
> >>
> >>Richard
> >>
> >>--- Daniel-Constantin Mierla <daniel@iptel.org>
> >>wrote:
> >>    
> >>
> >>>Hello,
> >>>the usual way is that the contributor sends the
> >>>patch to the list, the 
> >>>maintainer of the module reviews it and if he
> >>>      
> >>>
> >>agrees
> >>    
> >>
> >>>will commit the 
> >>>changes. Otherwise, there might be other users
> >>>      
> >>>
> >>that
> >>    
> >>
> >>>will use your 
> >>>development even the maintainer disagrees the
> >>>changes.
> >>>
> >>>.Daniel
> >>>
> >>>On 4/30/2004 10:51 AM, Richard wrote:
> >>>
> >>>      
> >>>
> >>>>Hi,
> >>>>
> >>>>Is it possible to add a new function in module
> >>>>        
> >>>>
> >>>domain?
> >>>      
> >>>
> >>>>It checks if the from uri and request uri
> belongs
> >>>>        
> >>>>
> >>>to
> >>>      
> >>>
> >>>>the same domain. It helps preventing
> inter-domain
> >>>>calls in a multiple domain scenario.
> >>>>
> >>>>The function is relatively simple. It just
> >>>>        
> >>>>
> >>compares
> >>    
> >>
> >>>>the host part of two uri's. User script can call
> >>>>        
> >>>>
> >>>this
> >>>      
> >>>
> >>>>function followed by is_from_local to make sure
> >>>>        
> >>>>
> >>the
> >>    
> >>
> >>>>domain exists.
> >>>>
> >>>>Thanks,
> >>>>Richard
> >>>>
> >>>>
> >>>>
> >>>>	
> >>>>		
> >>>>__________________________________
> >>>>Do you Yahoo!?
> >>>>Win a $20,000 Career Makeover at Yahoo! HotJobs 
> 
> >>>>        
> >>>>
>
>>>http://hotjobs.sweepstakes.yahoo.com/careermakeover
> >>>
> >>>      
> >>>
> >>>>_______________________________________________
> >>>>Serdev mailing list
> >>>>Serdev@iptel.org
> >>>>http://mail.iptel.org/mailman/listinfo/serdev
> >>>>
> >>>> 
> >>>>
> >>>>        
> >>>>
> >>
> 
=== message truncated ===



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 
-------------- next part --------------
Only in domain: CVS
Only in domain: doc
diff -u -r domain.old/domain.c domain/domain.c
--- domain.old/domain.c	2004-04-30 07:32:33.000000000 -1000
+++ domain/domain.c	2004-04-30 07:22:45.000000000 -1000
@@ -119,3 +119,44 @@
 
 	return is_domain_local(&(_msg->parsed_uri.host));
 }
+
+/*
+ * Check if domains of from and request URI are same
+ */
+int is_intra_domain(struct sip_msg* _msg, char* _s1, char* _s2) {
+	str uri;
+	struct sip_uri puri;
+
+	if (db_mode == 0) {
+		return 1;
+	}
+
+	if (parse_from_header(_msg) < 0) {
+		LOG(L_ERR, "is_from_local(): Error while parsing From header\n");
+		return -2;
+	}
+
+	uri = get_from(_msg)->uri;
+
+	if (parse_uri(uri.s, uri.len, &puri) < 0) {
+		LOG(L_ERR, "is_from_local(): Error while parsing URI\n");
+		return -3;
+	}
+
+	if (parse_sip_msg_uri(_msg) < 0) {
+	    LOG(L_ERR, "is_uri_host_local(): Error while parsing URI\n");
+	    return -1;
+	}
+
+	if (puri.host.len != (_msg->parsed_uri.host).len) {
+			return -1;
+	}
+
+	if (strncasecmp(puri.host.s, _msg->parsed_uri.host.s, puri.host.len)==0) {
+		return 1;
+	} else {
+		return -1;
+	}
+}
+
+
diff -u -r domain.old/domain.h domain/domain.h
--- domain.old/domain.h	2004-04-30 07:32:33.000000000 -1000
+++ domain/domain.h	2004-04-30 07:27:46.000000000 -1000
@@ -46,4 +46,10 @@
 int is_uri_host_local(struct sip_msg* _msg, char* _s1, char* _s2);
 
 
+/*
+ * Check if domains of from and request URI are same
+ */
+int is_intra_domain(struct sip_msg* _msg, char* _s1, char* _s2);
+
+
 #endif /* DOMAIN_H */
diff -u -r domain.old/domain_mod.c domain/domain_mod.c
--- domain.old/domain_mod.c	2004-04-30 07:32:33.000000000 -1000
+++ domain/domain_mod.c	2004-04-29 22:44:22.000000000 -1000
@@ -88,6 +88,7 @@
 static cmd_export_t cmds[] = {
 	{"is_from_local",     is_from_local,     0, 0, REQUEST_ROUTE},
 	{"is_uri_host_local", is_uri_host_local, 0, 0, REQUEST_ROUTE},
+	{"is_intra_domain", is_intra_domain, 0, 0, REQUEST_ROUTE},
 	{0, 0, 0, 0, 0}
 };
 
Only in domain.old: domain.so.old

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic