Kaynağa Gözat

Merge branch 'master' of ssh://git.sip-router.org/sip-router

* 'master' of ssh://git.sip-router.org/sip-router:
  Makefile.defs: version set 3.4.0-dev2
  parser/sdp: more suggestive debug message
  parser/sdp: prevent manipulation with freed structure
  core: Removed unused enum (crept in during WebSocket implementation)
  modules/ipops: Corrected is_in_subnet() exported function and added is_ip to module C API
  modules/sl: Fixed segmentation fault and corrected log messages
  modules_k/registrar: Fixed some errors in module documentation
  core: update printing of socket lists to show the advertised address if set for the socket
  modules_k/presence: Added missing use_table() call
Peter Dunkley 13 yıl önce
ebeveyn
işleme
e570709eeb

+ 1 - 1
Makefile.defs

@@ -162,7 +162,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 VERSION = 3
 PATCHLEVEL = 4
 SUBLEVEL =  0
-EXTRAVERSION = -dev1
+EXTRAVERSION = -dev2
 
 # memory debugger switcher
 # 0 - off (release mode)

+ 12 - 0
modules/ipops/api.c

@@ -117,6 +117,17 @@ int ipopsapi_ip_is_in_subnet(const str *const ip1, const str *const ip2)
     return -1;
 }
 
+/**
+ *
+ */
+int ipopsapi_is_ip(const str * const ip)
+{
+  if (ip_parser_execute(ip->s, ip->len) != ip_type_error)
+    return 1;
+  else
+    return -1;
+}
+
 /**
  *
  */
@@ -128,6 +139,7 @@ int bind_ipops(ipops_api_t* api)
 	}
 	api->compare_ips     = ipopsapi_compare_ips;
 	api->ip_is_in_subnet = ipopsapi_ip_is_in_subnet;
+	api->is_ip           = ipopsapi_is_ip;
 
 	return 0;
 }

+ 3 - 0
modules/ipops/api.h

@@ -36,12 +36,15 @@ int ipopsapi_compare_ips(const str *const ip1, const str *const ip2);
 typedef int (*ip_is_in_subnet_f)(const str *const, const str *const);
 int ipopsapi_ip_is_in_subnet(const str *const ip1, const str *const ip2);
 
+typedef int (*is_ip_f)(const str * const ip);
+int ipopsapi_is_ip(const str * const ip);
 /**
  * @brief IPOPS API structure
  */
 typedef struct ipops_api {
 	compare_ips_f       compare_ips;
 	ip_is_in_subnet_f   ip_is_in_subnet;
+	is_ip_f   is_ip;
 } ipops_api_t;
 
 typedef int (*bind_ipops_f)(ipops_api_t* api);

+ 1 - 1
modules/ipops/ipops_mod.c

@@ -108,7 +108,7 @@ static cmd_export_t cmds[] =
   REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE },
   { "is_ip_rfc1918", (cmd_function)w_is_ip_rfc1918, 1, fixup_spve_null, 0,
   REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE },
-  { "is_in_subnet", (cmd_function)w_ip_is_in_subnet, 2, fixup_spve_null, 0,
+  { "is_in_subnet", (cmd_function)w_ip_is_in_subnet, 2, fixup_spve_spve, 0,
   REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE },
   { "bind_ipops", (cmd_function)bind_ipops, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0 }

+ 2 - 2
modules/sl/sl.c

@@ -209,7 +209,7 @@ static int w_sl_send_reply(struct sip_msg* msg, char* p1, char* p2)
     }
     
     if (get_str_fparam(&reason, msg, (fparam_t*)p2) < 0) {
-		reason = default_reason;;
+		reason = default_reason;
     }
 
 	if(reason.s[reason.len-1]=='\0') {
@@ -219,7 +219,7 @@ static int w_sl_send_reply(struct sip_msg* msg, char* p1, char* p2)
 		if (r == NULL) r = default_reason.s;
 	}
 	ret = sl_send_reply(msg, code, r);
-    if (r!=reason.s) pkg_free(r);
+    if ((r!=reason.s) && (r!=default_reason.s)) pkg_free(r);
     return ret;
 }
 

+ 1 - 1
modules/sl/sl_funcs.c

@@ -183,7 +183,7 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 	}
 	if (!buf.s)
 	{
-		DBG("DEBUG: sl_send_reply: response building failed\n");
+		DBG("DEBUG: sl_reply_helper: response building failed\n");
 		goto error;
 	}
 	

+ 8 - 0
modules_k/presence/notify.c

@@ -2777,6 +2777,14 @@ int process_dialogs(int round, int presence_winfo)
 		result_cols[updated_winfo_col = n_result_cols++] = &str_updated_winfo_col;
 		result_cols[expires_col = n_result_cols++] = &str_expires_col;
 
+		/* Need to redo this here as we might have switched to the
+		   presentity table during a previous iteration. */
+		if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
+		{
+			LM_ERR("use table failed\n");
+			goto error;
+		}
+
 		if (pa_dbf.start_transaction)
 		{
 			if (pa_dbf.start_transaction(pa_db) < 0)

+ 45 - 45
modules_k/registrar/README

@@ -16,7 +16,7 @@ Edited by
 
 Bogdan-Andre Iancu
 
-   Copyright © 2003 FhG FOKUS
+   Copyright © 2003 FhG FOKUS
      __________________________________________________________________
 
    Table of Contents
@@ -111,9 +111,9 @@ Bogdan-Andre Iancu
    1.24. lookup usage
    1.25. registered usage
    1.26. add_sock_hdr usage
-   1.27. registered usage
-   1.28. registered usage
-   1.29. registered usage
+   1.27. unregister usage
+   1.28. reg_fetch_contacts usage
+   1.29. reg_free_contacts usage
    1.30. $ulc(name) usage
 
 Chapter 1. Admin Guide
@@ -197,8 +197,8 @@ Chapter 1. Admin Guide
      * off - stores the value of the Path headers into usrloc without
        passing it back to the UAC in the reply.
      * lazy - stores the Path header and passes it back to the UAC if
-       Path-support is indicated by the "path" param in the Supported HF.
-     * strict - rejects the registration with "420 Bad Extension" if
+       Path-support is indicated by the “path� param in the Supported HF.
+     * strict - rejects the registration with “420 Bad Extension� if
        there's a Path header but no support for it is indicated by the
        UAC. Otherwise it's stored and passed back to the UAC.
 
@@ -210,8 +210,8 @@ Chapter 1. Admin Guide
    client's NAT).
 
    The whole process is transparent to the user, so no config changes are
-   required beside setting the registrar-parameters "use_path" and
-   "path_mode".
+   required beside setting the registrar-parameters “use_path� and
+   “path_mode�.
 
 1.2. GRUU Support
 
@@ -273,7 +273,7 @@ Chapter 1. Admin Guide
    contact parameters, this value will be used for newly created usrloc
    records. The parameter contains number of second to expire (for example
    use 3600 for one hour). If it is set to a lower value than the
-   "min_expires" parameter then it will be ignored. This parameter can be
+   “min_expires� parameter then it will be ignored. This parameter can be
    modified via ser config framework. A random value in a specific
    interval can be selected by using the default_expires_range parameter
 
@@ -287,9 +287,9 @@ modparam("registrar", "default_expires", 1800)
 3.2. default_expires_range (integer)
 
    This parameter specifies that the expiry used for newly created usrloc
-   records are not fixed(when "default_expires" applies), but a random
-   value in the interval "[default_expires-default_expires_range%,
-   default_expires+default_expires_range%]". The value is between 0 and
+   records are not fixed(when “default_expires� applies), but a random
+   value in the interval “[default_expires-default_expires_range%,
+   default_expires+default_expires_range%]�. The value is between 0 and
    100 and represent the maximim percentage from default_expires that will
    be substracted or added when computing the value. Default in 0, meaning
    default_expires is left unmodified. This parameter can be modified via
@@ -507,7 +507,7 @@ modparam("registrar", "method_filtering", 1)
 3.17. use_path (integer)
 
    If set to 1, the Path header is handled according to the parameter This
-   parameter can be modified via ser config framework. "path_mode".
+   parameter can be modified via ser config framework. “path_mode�.
 
    Default value is 0 (disabled).
 
@@ -524,12 +524,12 @@ modparam("registrar", "use_path", 1)
        the reply.
      * 1 - The Path header is saved into usrloc, but is only included in
        the reply if path support is indicated in the registration request
-       by the "path" option of the "Supported" header.
+       by the “path� option of the “Supported� header.
      * 2 - The path header is only saved into usrloc, if path support is
-       indicated in the registration request by the "path" option of the
-       "Supported" header. If no path support is indicated, the request is
-       rejected with "420 - Bad Extension" and the header "Unsupported:
-       path" is included in the reply along with the received "Path"
+       indicated in the registration request by the “path� option of the
+       “Supported� header. If no path support is indicated, the request is
+       rejected with “420 - Bad Extension� and the header “Unsupported:
+       path� is included in the reply along with the received “Path�
        header. This mode is the one recommended by RFC-3327.
 
    Default value is 2.
@@ -541,10 +541,10 @@ modparam("registrar", "path_mode", 0)
 
 3.19. path_use_received (integer)
 
-   If set to 1, the "received" parameter of the first Path URI of a
+   If set to 1, the “received� parameter of the first Path URI of a
    registration is set as received-uri and the NAT branch flag is set for
    this contact. This is useful if the registrar is placed behind a SIP
-   loadbalancer, which passes the nat'ed UAC address as "received"
+   loadbalancer, which passes the nat'ed UAC address as “received�
    parameter in it's Path uri.
 
    Default value is 0 (disabled).
@@ -605,7 +605,7 @@ modparam("registrar", "xavp_cfg", "ulrcd")
 
 3.23. gruu_enabled (integer)
 
-   If set to 1 and GRUU "+sip.instance" parameter to Contact header of
+   If set to 1 and GRUU “+sip.instance� parameter to Contact header of
    REGISTER is present, then the value of the parameter is saved to
    location and pub-gruu and temp-gruu addresses are generated.
 
@@ -628,7 +628,7 @@ modparam("registrar", "gruu_enabled", 0)
    4.6. reg_fetch_contacts(domain, uri, profile)
    4.7. reg_free_contacts(profile)
 
-4.1. save(domain, [, flags [, uri]])
+4.1.  save(domain, [, flags [, uri]])
 
    The function processes a REGISTER message. It can add, remove or modify
    usrloc records depending on Contact and Expires HFs in the REGISTER
@@ -672,7 +672,7 @@ save("location", "0x01");
 save("location", "0x00", "sip:[email protected]");
 ...
 
-4.2. lookup(domain [, uri])
+4.2.  lookup(domain [, uri])
 
    The functions extracts username from Request-URI and tries to find all
    contacts for the username in usrloc. If there are no such contacts, -1
@@ -712,7 +712,7 @@ switch ($retcode) {
 };
 ...
 
-4.3. registered(domain [, uri])
+4.3.  registered(domain [, uri])
 
    The function returns true if the AOR in the Request-URI is registered,
    false otherwise. The function does not modify the message being
@@ -734,9 +734,9 @@ if (registered("location")) {
 };
 ...
 
-4.4. add_sock_hdr(hdr_name)
+4.4.  add_sock_hdr(hdr_name)
 
-   Adds to the current REGISTER request a new header with "hdr_name" which
+   Adds to the current REGISTER request a new header with “hdr_name� which
    contains the description of the received socket (proto:ip:port)
 
    This make sens only in multiple replicated servers scenarios.
@@ -751,7 +751,7 @@ if (registered("location")) {
 add_sock_hdr("Sock-Info");
 ...
 
-4.5. unregister(domain, uri)
+4.5.  unregister(domain, uri)
 
    The function remove all the contact associated to 'uri'.
 
@@ -764,13 +764,13 @@ add_sock_hdr("Sock-Info");
 
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 
-   Example 1.27. registered usage
+   Example 1.27. unregister usage
 ...
 unregister("location", "$ru");
 unregister("location", "sip:[email protected]");
 ...
 
-4.6. reg_fetch_contacts(domain, uri, profile)
+4.6.  reg_fetch_contacts(domain, uri, profile)
 
    The function fetches the contacts for 'uri' from table 'domain' to
    pseudo-variable $ulc(profile).
@@ -786,13 +786,13 @@ unregister("location", "sip:[email protected]");
 
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 
-   Example 1.28. registered usage
+   Example 1.28. reg_fetch_contacts usage
 ...
 reg_fetch_contacts("location", "$ru", "callee");
 reg_fetch_contacts("location", "sip:[email protected]", "caller");
 ...
 
-4.7. reg_free_contacts(profile)
+4.7.  reg_free_contacts(profile)
 
    The function frees the contacts from pseudo-variable $ulc(profile).
    Should be called to release the content of a profile. Anyhow, fetching
@@ -805,7 +805,7 @@ reg_fetch_contacts("location", "sip:[email protected]", "caller");
 
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 
-   Example 1.29. registered usage
+   Example 1.29. reg_free_contacts usage
 ...
 reg_free_contacts("callee");
 ...
@@ -845,12 +845,12 @@ reg_free_contacts("callee");
 6.1. $ulc(profile=>attr)
 
    Access the attributes of contact addresses stored in 'profile'. It must
-   be used after a call of "reg_fetch_contacts()".
+   be used after a call of “reg_fetch_contacts()�.
 
-   The "profile" has to be one of the values used with
-   "reg_fetch_contacts()".
+   The “profile� has to be one of the values used with
+   “reg_fetch_contacts()�.
 
-   The "attr" can be:
+   The “attr� can be:
      * aor - address of record
      * domain - use location domain name
      * aorhash - hash id for the record
@@ -903,9 +903,9 @@ if(reg_fetch_contacts("location", "$fu", "caller"))
 
 Chapter 2. Frequently Asked Questions
 
-   2.1. What happend with the old "nat_flag" module parameter?
-   2.2. What happend with the old "use_domain" module parameter?
-   2.3. What happend with the old "save_noreply" and "save_memory"
+   2.1. What happend with the old “nat_flag� module parameter?
+   2.2. What happend with the old “use_domain� module parameter?
+   2.3. What happend with the old “save_noreply� and “save_memory�
           functions?
 
    2.4. Where can I find more about Kamailio?
@@ -915,23 +915,23 @@ Chapter 2. Frequently Asked Questions
 
    2.1.
 
-   What happend with the old "nat_flag" module parameter?
+   What happend with the old “nat_flag� module parameter?
 
    In was removed, as the module internally loads this value from the
-   "USRLOC" module (see the "nat_bflag" USRLOC parameter).
+   “USRLOC� module (see the “nat_bflag� USRLOC parameter).
 
    2.2.
 
-   What happend with the old "use_domain" module parameter?
+   What happend with the old “use_domain� module parameter?
 
    In was removed, as the module internally loads this option from the
-   "USRLOC" module. This was done in order to simplify the configuration.
+   “USRLOC� module. This was done in order to simplify the configuration.
 
    2.3.
 
-   What happend with the old "save_noreply" and "save_memory" functions?
+   What happend with the old “save_noreply� and “save_memory� functions?
 
-   There functions were merged into the new "save(domain,flags)"
+   There functions were merged into the new “save(domain,flags)�
    functions. If a reply should be sent or if the DB should be updated
    also is controlled via the flags.
 

+ 3 - 3
modules_k/registrar/doc/registrar_admin.xml

@@ -985,7 +985,7 @@ add_sock_hdr("Sock-Info");
 		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 		</para>
 		<example>
-		<title><function>registered</function> usage</title>
+		<title><function>unregister</function> usage</title>
 		<programlisting format="linespecific">
 ...
 unregister("location", "$ru");
@@ -1028,7 +1028,7 @@ unregister("location", "sip:[email protected]");
 		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 		</para>
 		<example>
-		<title><function>registered</function> usage</title>
+		<title><function>reg_fetch_contacts</function> usage</title>
 		<programlisting format="linespecific">
 ...
 reg_fetch_contacts("location", "$ru", "callee");
@@ -1060,7 +1060,7 @@ reg_fetch_contacts("location", "sip:[email protected]", "caller");
 		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 		</para>
 		<example>
-		<title><function>registered</function> usage</title>
+		<title><function>reg_free_contacts</function> usage</title>
 		<programlisting format="linespecific">
 ...
 reg_free_contacts("callee");

+ 2 - 1
parser/sdp/sdp.c

@@ -717,8 +717,9 @@ int parse_sdp(struct sip_msg* _m)
 			}
 			res = parse_sdp_session(&body, 0, NULL, (sdp_info_t*)_m->body);
 			if (res != 0) {
-				LM_DBG("free_sdp\n");
+				LM_DBG("failed to parse sdp session - freeing sdp\n");
 				free_sdp((sdp_info_t**)(void*)&_m->body);
+				return res;
 			}
 			/* The whole body is SDP */
 			((sdp_info_t*)_m->body)->raw_sdp.s = body.s;

+ 1 - 2
route_struct.h

@@ -136,8 +136,7 @@ enum _operand_subtype{
 		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
 		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
 		FPARAM_DYN_ST /* temporary only (fparam hack) */,
-		CFG_GROUP_ST,
-		WEBSOCKET_ST
+		CFG_GROUP_ST
 };
 
 typedef enum _expr_l_type expr_l_type;

+ 4 - 1
socket_info.c

@@ -2012,10 +2012,13 @@ void print_all_socket_lists()
 						si->name.s);
 				if (!si->flags & SI_IS_IP)
 					printf(" [%s]", si->address_str.s);
-				printf( ":%s%s%s\n",
+				printf( ":%s%s%s",
 						si->port_no_str.s, 
 						si->flags & SI_IS_MCAST ? " mcast" : "",
 						si->flags & SI_IS_MHOMED? " mhomed" : "");
+				if (si->useinfo.name.s)
+					printf(" advertise %s", si->useinfo.name.s);
+				printf("\n");
 			}
 		}
 	}while((proto=next_proto(proto)));