sipops.c

Go to the documentation of this file.
00001 /*
00002  * $Id: utils.h 5318 2008-12-08 16:38:47Z henningw $
00003  *
00004  * SIPUTILS mangler module
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of SIP-router, a free SIP server.
00009  *
00010  * SIP-router is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * SIP-router is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00034 #include "../../mod_fix.h"
00035 #include "../../parser/parse_uri.h"
00036 #include "../../lib/kcore/cmpapi.h"
00037 
00038 #include "sipops.h"
00039 
00040 int w_cmp_uri(struct sip_msg *msg, char *uri1, char *uri2)
00041 {
00042         str s1;
00043         str s2;
00044         int ret;
00045 
00046         if(fixup_get_svalue(msg, (gparam_p)uri1, &s1)!=0)
00047         {
00048                 LM_ERR("cannot get first parameter\n");
00049                 return -8;
00050         }
00051         if(fixup_get_svalue(msg, (gparam_p)uri2, &s2)!=0)
00052         {
00053                 LM_ERR("cannot get second parameter\n");
00054                 return -8;
00055         }
00056         ret = cmp_uri_str(&s1, &s2);
00057         if(ret==0)
00058                 return 1;
00059         if(ret>0)
00060                 return -1;
00061         return -2;
00062 }
00063 
00064 int w_cmp_aor(struct sip_msg *msg, char *uri1, char *uri2)
00065 {
00066         str s1;
00067         str s2;
00068         int ret;
00069 
00070         if(fixup_get_svalue(msg, (gparam_p)uri1, &s1)!=0)
00071         {
00072                 LM_ERR("cannot get first parameter\n");
00073                 return -8;
00074         }
00075         if(fixup_get_svalue(msg, (gparam_p)uri2, &s2)!=0)
00076         {
00077                 LM_ERR("cannot get second parameter\n");
00078                 return -8;
00079         }
00080         ret = cmp_aor_str(&s1, &s2);
00081         if(ret==0)
00082                 return 1;
00083         if(ret>0)
00084                 return -1;
00085         return -2;
00086 }
00087 
00088 int w_is_gruu(sip_msg_t *msg, char *uri1, char *p2)
00089 {
00090         str s1;
00091         sip_uri_t turi;
00092         sip_uri_t *puri;
00093 
00094         if(uri1!=NULL)
00095         {
00096                 if(fixup_get_svalue(msg, (gparam_p)uri1, &s1)!=0)
00097                 {
00098                         LM_ERR("cannot get first parameter\n");
00099                         return -8;
00100                 }
00101                 if(parse_uri(s1.s, s1.len, &turi)!=0)
00102                         return -1;
00103                 puri = &turi;
00104         } else {
00105                 if(parse_sip_msg_uri(msg))
00106                         return -1;
00107                 puri = &msg->parsed_uri;
00108         }
00109         if(puri->gr.s!=NULL)
00110         {
00111                 if(puri->gr_val.len>0)
00112                         return 1;
00113                 return 2;
00114         }
00115         return -1;
00116 }