Selaa lähdekoodia

topos: expose rcv data in event routes

Updated documentation.
Stefan Mititelu 2 kuukautta sitten
vanhempi
commit
90b350a281
2 muutettua tiedostoa jossa 30 lisäystä ja 17 poistoa
  1. 24 17
      src/modules/topos/doc/topos_admin.xml
  2. 6 0
      src/modules/topos/topos_mod.c

+ 24 - 17
src/modules/topos/doc/topos_admin.xml

@@ -659,14 +659,12 @@ request_route {
 		<para>
 		<para>
 		It is executed before doing topology stripping processing for an outgoing
 		It is executed before doing topology stripping processing for an outgoing
 		SIP message. If 'drop' is executed inside the event route, then the
 		SIP message. If 'drop' is executed inside the event route, then the
-		module skips doing the topology hiding.
+		module skips doing the <emphasis>out part of</emphasis> topology hiding.
 		</para>
 		</para>
 		<para>
 		<para>
+		Only fake msg is available in this event route.
 		Inside the event route the variables $sndto(ip), $sndto(port) and
 		Inside the event route the variables $sndto(ip), $sndto(port) and
-		$sndto(proto) point to the destination. The SIP message is not the one
-		to be sent out, but an internally generated one at startup, to avoid
-		reparsing the outgoing SIP message for the cases when topology hiding
-		is not wanted.
+		$sndto(proto) point to the destination.
 		</para>
 		</para>
 		<example>
 		<example>
 		<title>Usage of event_route[topos:msg-outgoing]</title>
 		<title>Usage of event_route[topos:msg-outgoing]</title>
@@ -686,11 +684,13 @@ event_route[topos:msg-outgoing] {
 		<para>
 		<para>
 		It is executed before doing topology stripping processing for a SIP
 		It is executed before doing topology stripping processing for a SIP
 		message to be sent out, being executed after event_route[topos:msg-outgoing].
 		message to be sent out, being executed after event_route[topos:msg-outgoing].
+		If 'drop' is executed inside the event route, then the
+		module skips doing the <emphasis>out part of</emphasis> topology hiding.
 		</para>
 		</para>
 		<para>
 		<para>
+		A copy of the SIP msg to be sent out is available in this event route.
 		Inside the event route the variables $sndto(ip), $sndto(port) and
 		Inside the event route the variables $sndto(ip), $sndto(port) and
-		$sndto(proto) point to the destination. The SIP message is the one
-		to be sent out.
+		$sndto(proto) point to the destination.
 		</para>
 		</para>
 		<example>
 		<example>
 		<title>Usage of event_route[topos:msg-sending]</title>
 		<title>Usage of event_route[topos:msg-sending]</title>
@@ -709,15 +709,12 @@ event_route[topos:msg-sending] {
 		<title>event_route[topos:msg-incoming]</title>
 		<title>event_route[topos:msg-incoming]</title>
 		<para>
 		<para>
 		It is executed before doing topology stripping processing for an incoming
 		It is executed before doing topology stripping processing for an incoming
-		SIP message. If 'drop' is executed inside the event route, then the
-		module skips doing the topology hiding.
+		SIP message. If 'drop' is executed inside this event route, then the
+		module skips doing the <emphasis>in part of</emphasis> topology hiding.
 		</para>
 		</para>
 		<para>
 		<para>
-		Inside the event route the variables $si, $sp and
-		$proto point to the source address. The SIP message is not the one
-		to be sent out, but an internally generated one at startup, to avoid
-		reparsing the outgoing SIP message for the cases when topology hiding
-		is not wanted.
+		Only fake msg is available in this event route.
+		$si, $sp and $proto will have default fake values.
 		</para>
 		</para>
 		<example>
 		<example>
 		<title>Usage of event_route[topos:msg-incoming]</title>
 		<title>Usage of event_route[topos:msg-incoming]</title>
@@ -737,11 +734,13 @@ event_route[topos:msg-incoming] {
 		<para>
 		<para>
 		It is executed before doing topology stripping processing for a SIP
 		It is executed before doing topology stripping processing for a SIP
 		message that was received, being executed after event_route[topos:msg-incoing].
 		message that was received, being executed after event_route[topos:msg-incoing].
+		If 'drop' is executed inside this event route, then the
+		module skips doing the <emphasis>in part of</emphasis> topology hiding.
 		</para>
 		</para>
 		<para>
 		<para>
-		Inside the event route the variables $si, $sp and
-		$proto point to the source address. The SIP message is the one
-		to be sent out.
+		A copy of the received SIP msg is available in this event route.
+		$si, $sp and $proto will have correct, expected values.
+		Also src_port and dst_port can be used here.
 		</para>
 		</para>
 		<example>
 		<example>
 		<title>Usage of event_route[topos:msg-receiving]</title>
 		<title>Usage of event_route[topos:msg-receiving]</title>
@@ -751,6 +750,14 @@ event_route[topos:msg-receiving] {
   if(is_request() and $fU=="alice") {
   if(is_request() and $fU=="alice") {
     drop;
     drop;
   }
   }
+
+  if($sp==5555 || $si=="1.2.3.4") {
+    drop;
+  }
+
+  if(src_port==1234 || dst_port==5678) {
+    drop;
+  }
 }
 }
 ...
 ...
 </programlisting>
 </programlisting>

+ 6 - 0
src/modules/topos/topos_mod.c

@@ -524,6 +524,9 @@ int tps_msg_received(sr_event_param_t *evp)
 	memset(&msg, 0, sizeof(sip_msg_t));
 	memset(&msg, 0, sizeof(sip_msg_t));
 	msg.buf = obuf->s;
 	msg.buf = obuf->s;
 	msg.len = obuf->len;
 	msg.len = obuf->len;
+	if(evp->rcv) {
+		msg.rcv = *(receive_info_t *)evp->rcv;
+	}
 
 
 	ret = 0;
 	ret = 0;
 	if(tps_prepare_msg(&msg) != 0) {
 	if(tps_prepare_msg(&msg) != 0) {
@@ -601,6 +604,9 @@ int tps_msg_sent(sr_event_param_t *evp)
 	memset(&msg, 0, sizeof(sip_msg_t));
 	memset(&msg, 0, sizeof(sip_msg_t));
 	msg.buf = obuf->s;
 	msg.buf = obuf->s;
 	msg.len = obuf->len;
 	msg.len = obuf->len;
+	if(evp->rcv) {
+		msg.rcv = *(receive_info_t *)evp->rcv;
+	}
 
 
 	if(tps_prepare_msg(&msg) != 0) {
 	if(tps_prepare_msg(&msg) != 0) {
 		goto done;
 		goto done;