Răsfoiți Sursa

- sl_send_reply with reply_to_via==0 (default) fixed (hopefully)

Andrei Pelinescu-Onciul 22 ani în urmă
părinte
comite
20581c5ac2
5 a modificat fișierele cu 29 adăugiri și 2 ștergeri
  1. 2 1
      TODO
  2. 1 0
      forward.c
  3. 3 0
      forward.h
  4. 20 0
      ip_addr.h
  5. 3 1
      timer.c

+ 2 - 1
TODO

@@ -71,7 +71,7 @@ x jku: branch hash computation over canonical values
 x freopen stdin, stdout, stderr to /dev/null
 - add a section on building ser & configuring it for maximum performance
  (-DF_MALLOC, -DNO_DBG, ... sip_warning=0, a.s.o)
-- add src_port, dst_port, proto to cfg.{y,lex}
+x add src_port, dst_port, proto to cfg.{y,lex}
 x generic locking lib
 x convert tm to use new locking lib
 - force add rport (setflag(rport)???)
@@ -79,6 +79,7 @@ x convert tm to use new locking lib
 
 optimizations:
 - better timer interface with hashes (a la openbsd)
+- change lumps (flags for malloc type, recursive? see COND lumps )
 - atomic ops?
 - assembly for some very common used function
 - getsock* cache

+ 1 - 0
forward.c

@@ -36,6 +36,7 @@
  *               calls to msg_send (andrei)
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  *  2003-04-02  fixed get_send_socket for tcp fwd to udp (andrei)
+ *  2003-04-03  added su_setport (andrei)
  */
 
 

+ 3 - 0
forward.h

@@ -55,8 +55,11 @@ int check_self(str* host, unsigned short port);
 int forward_request( struct sip_msg* msg,  struct proxy_l* p, int proto);
 int update_sock_struct_from_via( union sockaddr_union* to,
 								struct via_body* via );
+
+/* use src_ip, port=src_port if rport, via port if via port, 5060 otherwise */
 #define update_sock_struct_from_ip(  to, msg ) \
 	init_su((to), &(msg)->rcv.src_ip, \
+			((msg)->via1->rport)?htons((msg)->rcv.src_port): \
 			((msg)->via1->port)?htons((msg)->via1->port): htons(SIP_PORT) )
 
 int forward_reply( struct sip_msg* msg);

+ 20 - 0
ip_addr.h

@@ -259,6 +259,26 @@ static inline short su_getport(union sockaddr_union* su)
 
 
 
+/* sets the port number */
+static inline void su_setport(union sockaddr_union* su, unsigned short port)
+{
+	switch(su->s.sa_family){
+		case AF_INET:
+			su->sin.sin_port=port;
+			break;
+#ifdef USE_IPV6
+		case AF_INET6:
+			 su->sin6.sin6_port=port;
+			 break;
+#endif
+		default:
+			LOG(L_CRIT,"su_set_port: BUG: unknown address family %d\n",
+						su->s.sa_family);
+	}
+}
+
+
+
 /* inits an ip_addr pointer from a sockaddr_union ip address */
 static inline void su2ip_addr(struct ip_addr* ip, union sockaddr_union* su)
 {

+ 3 - 1
timer.c

@@ -94,7 +94,9 @@ void destroy_timer()
 
 
 /*register a periodic timer;
- * ret: <0 on error*/
+ * ret: <0 on error
+ * Hint: if you need it in a module, register it from mod_init or it 
+ * won't work otherwise*/
 int register_timer(timer_function f, void* param, unsigned int interval)
 {
 	struct sr_timer* t;