浏览代码

Merge remote branch 'origin/tmp/k3.0_sr_backports' into sr_3.0

* origin/tmp/k3.0_sr_backports:
  modules/mediaproxy: properly fix the IP in the RTCP line
  utils/kamctl: removed unsupported commands to manage lcr gateways and routes
  cfg.y: fix warnings introduced in previous commit
  core: added forward()
  Makefile: MEMDBG var to control mem debugging mode
Andrei Pelinescu-Onciul 15 年之前
父节点
当前提交
385ce10271
共有 5 个文件被更改,包括 49 次插入34 次删除
  1. 10 3
      Makefile.defs
  2. 2 1
      cfg.y
  3. 37 0
      modules/mediaproxy/mediaproxy.c
  4. 0 15
      utils/kamctl/kamctl.8
  5. 0 15
      utils/kamctl/kamctl.base

+ 10 - 3
Makefile.defs

@@ -146,6 +146,11 @@ PATCHLEVEL = 99
 SUBLEVEL =  99
 EXTRAVERSION = -pre3
 
+# memory debugger switcher
+# 0 - off (release mode)
+# 1 - on (devel mode)
+MEMDBG ?= 1
+
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
 			$(SUBLEVEL) )
 RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -613,15 +618,12 @@ C_DEFS= $(extra_defs) \
 	 -DUSE_DNS_FAILOVER \
 	 -DUSE_DST_BLACKLIST \
 	 -DUSE_NAPTR \
-	 -DDBG_QM_MALLOC \
 	 #-DUSE_DNS_CACHE_STATS \
 	 #-DUSE_DST_BLACKLIST_STATS \
 	 #-DDNS_WATCHDOG_SUPPORT \
 	 #-DLL_MALLOC \
 	 #-DSF_MALLOC \
 	 #-DDL_MALLOC \
-	 #-DF_MALLOC \
-	 #-DDBG_QM_MALLOC \
 	 #-DDBG_F_MALLOC \
 	 #-DNO_DEBUG \
 	 #-DEXTRA_DEBUG \
@@ -641,6 +643,11 @@ C_DEFS= $(extra_defs) \
 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
 # debugging symbols in all cases (-g). --andrei
 
+ifeq ($(MEMDBG), 1)
+	C_DEFS+= -DDBG_QM_MALLOC
+else
+	C_DEFS+= -DF_MALLOC
+endif
 ifeq ($(CORE_TLS), 1)
 	C_DEFS+= -DUSE_TLS -DCORE_TLS
 endif

+ 2 - 1
cfg.y

@@ -2725,7 +2725,8 @@ avpflag_oper:
 	| ISAVPFLAGSET { $$ = -1; }
 	;
 cmd:
-	FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
+	FORWARD LPAREN RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
+	| FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
 	| FORWARD LPAREN STRING RPAREN	{ $$=mk_action(	FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
 	| FORWARD LPAREN ip RPAREN	{ $$=mk_action(	FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
 	| FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }

+ 37 - 0
modules/mediaproxy/mediaproxy.c

@@ -128,6 +128,7 @@ typedef struct {
     str type;      // stream type (`audio', `video', `image', ...)
     str ip;
     str port;
+    str rtcp_ip;   // pointer to the rtcp IP if explicitly specified by stream
     str rtcp_port; // pointer to the rtcp port if explicitly specified by stream
     str direction;
     Bool local_ip; // true if the IP is locally defined inside this media stream
@@ -872,6 +873,34 @@ get_rtcp_port_attribute(str *block)
 }
 
 
+// will return the rtcp IP of the stream in the given block
+// if defined by the stream, otherwise will return {NULL, 0}.
+static str
+get_rtcp_ip_attribute(str *block)
+{
+    str zone, tokens[4], undefined = {NULL, 0};
+    char *ptr;
+    int count;
+
+    ptr = find_line_starting_with(block, "a=rtcp:", False);
+
+    if (!ptr)
+        return undefined;
+
+    zone.s = ptr + 7;
+    zone.len = findendline(zone.s, block->s + block->len - zone.s) - zone.s;
+
+    count = get_str_tokens(&zone, tokens, 4);
+
+    if (count != 4) {
+        LM_ERR("invalid `a=rtcp' line in SDP body\n");
+        return undefined;
+    }
+
+    return tokens[3];
+}
+
+
 // will return the ip address present in a `c=' line in the given block
 // returns: -1 on error, 0 if not found, 1 if found
 static int
@@ -1118,6 +1147,7 @@ get_session_info(str *sdp, SessionInfo *session)
             session->streams[i].local_ip = 1;
         }
 
+        session->streams[i].rtcp_ip = get_rtcp_ip_attribute(&block);
         session->streams[i].rtcp_port = get_rtcp_port_attribute(&block);
         session->streams[i].direction = get_direction_attribute(&block, &session->direction);
     }
@@ -1536,6 +1566,13 @@ use_media_proxy(struct sip_msg *msg, char *dialog_id)
             }
         }
 
+        if (stream.rtcp_ip.len > 0) {
+            if (!replace_element(msg, &stream.rtcp_ip, &tokens[0])) {
+                LM_ERR("failed to replace RTCP IP in media stream number %d\n", i+1);
+                return -1;
+            }
+        }
+
         if (stream.local_ip && !isnulladdr(stream.ip)) {
             if (!replace_element(msg, &stream.ip, &tokens[0])) {
                 LM_ERR("failed to replace IP address in media stream number %d\n", i+1);

+ 0 - 15
utils/kamctl/kamctl.8

@@ -57,26 +57,11 @@ Grant user membership(s) (*)
 .TP 16
 .I  Least cost routes (lcr) managment command:
 .TP             
-.B lcr show 
-Show gateways and routes tables
-.TP
 .B lcr dump
 Show in memory gateways and routes tables
 .TP
 .B lcr reload 
 Reload lcr gateways and routes
-.TP
-.B lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <flags> <tag> <strip> <weight> <hostname> <ping>
-Add a gateway with flags, tag, strip, weight, hostname, and ping (flags, tag, strip, weight, hostname, and ping are optional)
-.TP
-.B lcr rmgw <gw_name> 
-Delete a gateway
-.TP
-.B lcr addroute <prefix> <from> <grp_id> <prio>
-Add a route ( use '' to match anything in <from> )
-.TP
-.B lcr rmroute <prefix> <from> <grp_id> <prio>
-Delete a route
 
 .TP 16
 .I Carrierroute tables('cr') managment commands:

+ 0 - 15
utils/kamctl/kamctl.base

@@ -362,23 +362,8 @@ usage_lcr() {
 	mecho " -- command 'lcr' - manage least cost routes (lcr)"
 	echo
 cat <<EOF
-   * IP addresses must be entered in dotted quad format e.g. 1.2.3.4   *
-   * <uri_scheme> and <transport> must be entered in integer or text,  *
-   * e.g. transport '2' is identical to transport 'tcp'.               *
-   *   scheme: 1=sip, 2=sips;   transport: 1=udp, 2=tcp, 3=tls, 4=sctp *
-   * Examples:  lcr addgw level3 1.2.3.4 5080 sip tcp 1                *
-   *            lcr addroute +1 '' 1 1                                 *
- lcr show .......... show gateways and routes tables
  lcr dump .......... show in memory gateways and routes tables
  lcr reload ........ reload lcr gateways and routes
- lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <flags> <tag> <strip> <weight> <hostname> <ping>
-           ......... add a gateway with flags, tag, strip, weight, hostname, and ping
-           ......... (flags, tag, strip, weight, hostname, and ping are optional)
- lcr rmgw <gw_name> delete a gateway
- lcr addroute <prefix> <from> <grp_id> <prio>
-           ......... add a route ( use '' to match anything in <from> )
- lcr rmroute <prefix> <from> <grp_id> <prio>
-           ......... delete a route
 EOF
 }
 USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_lcr"