소스 검색

sctp: connection reuse & connection tracking

- support for sctp connection tracking and true sctp connection
  reuse for replies.
  We need this to support reply connection reuse with asymmetric
  sctp peers (while there is no reason not to use the same port on
  sctp for sending and receiving messages and it should be
  strongly discouraged to do so, we never now with what
  implementation we'll have to deal).
  What  makes this particularly complex is the not-yet-complete
  sctp API, the slight but important behaviour
  differences between its linux, freebsd and solaris
  implementations and the fact that is more geared towards serial
  single threaded application rather then parallel-processing
  multi-process or multi-threaded ones.

- keep track of the number of active and tracked sctp connections

- blacklist moved into sctp_handles_assoc_change()
Andrei Pelinescu-Onciul 16 년 전
부모
커밋
31fd952ba8
5개의 변경된 파일1047개의 추가작업 그리고 7개의 파일을 삭제
  1. 10 1
      forward.c
  2. 8 0
      main.c
  3. 14 6
      msg_translator.c
  4. 1004 0
      sctp_server.c
  5. 11 0
      sctp_server.h

+ 10 - 1
forward.c

@@ -641,11 +641,20 @@ int forward_reply(struct sip_msg* msg)
 	dst.comp=msg->via2->comp_no;
 #endif
 
+#if defined USE_TCP || defined USE_SCTP
+	if (
 #ifdef USE_TCP
-	if (dst.proto==PROTO_TCP
+			dst.proto==PROTO_TCP
 #ifdef USE_TLS
 			|| dst.proto==PROTO_TLS
 #endif
+#ifdef USE_SCTP
+			||
+#endif /* USE_SCTP */
+#endif /* USE_TCP */
+#ifdef USE_SCTP
+			dst.proto==PROTO_SCTP
+#endif /* USE_SCTP */
 			){
 		/* find id in i param if it exists */
 		if (msg->via1->i && msg->via1->i->value.s){

+ 8 - 0
main.c

@@ -1959,6 +1959,14 @@ try_again:
 		}
 	}
 #endif /* USE_TCP */
+#ifdef USE_SCTP
+	if (!sctp_disable){
+		if (init_sctp()<0){
+			LOG(L_CRIT, "Could not initialize sctp, exiting...\n");
+			goto error;
+		}
+	}
+#endif /* USE_SCTP */
 	/* init_daemon? */
 	if (!dont_fork){
 		if ( daemonize(argv[0]) <0 ) goto error;

+ 14 - 6
msg_translator.c

@@ -2287,7 +2287,7 @@ char* create_via_hf( unsigned int *len,
 	char* via;
 	str extra_params;
 	struct hostport hp;
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	char* id_buf;
 	unsigned int id_len;
 
@@ -2299,13 +2299,21 @@ char* create_via_hf( unsigned int *len,
 	extra_params.s=0;
 
 
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	/* add id if tcp */
-	if (msg
-	&& ((msg->rcv.proto==PROTO_TCP)
+	if (msg && (
+#ifdef USE_TCP
+		(msg->rcv.proto==PROTO_TCP)
 #ifdef USE_TLS
 			|| (msg->rcv.proto==PROTO_TLS)
 #endif
+#ifdef USE_SCTP
+			||
+#endif /* USE_SCTP */
+#endif /* USE_TCP */
+#ifdef USE_SCTP
+			(msg->rcv.proto==PROTO_SCTP)
+#endif /* USE_SCTP */
 			)){
 		if  ((id_buf=id_builder(msg, &id_len))==0){
 			LOG(L_ERR, "ERROR: create_via_hf:"
@@ -2318,13 +2326,13 @@ char* create_via_hf( unsigned int *len,
 		extra_params.s=id_buf;
 		extra_params.len=id_len;
 	}
-#endif
+#endif /* USE_TCP || USE_SCTP */
 
 	set_hostport(&hp, msg);
 	via = via_builder( len, send_info, branch,
 							extra_params.len?&extra_params:0, &hp);
 
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	/* we do not need id_buf any more, the id is already in the new via header */
 	if (id_buf) pkg_free(id_buf);
 #endif

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1004 - 0
sctp_server.c


+ 11 - 0
sctp_server.h

@@ -29,12 +29,23 @@
 
 #include "ip_addr.h"
 
+struct sctp_gen_info{
+	int sctp_connections_no;
+	int sctp_tracked_no;
+	int sctp_total_connections;
+};
+
+int init_sctp();
+void destroy_sctp();
 int sctp_check_compiled_sockopts(char* buf, int size);
 int sctp_check_support();
 int sctp_init_sock(struct socket_info* sock_info);
 int sctp_rcv_loop();
 int sctp_msg_send(struct dest_info* dst, char* buf, unsigned len);
 
+/* generic sctp information (stats a.s.o) */
+void sctp_get_info(struct sctp_gen_info* sinf);
+
 void destroy_sctp();
 
 #endif /* _sctp_server_h */

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.