Browse code

sctp: new module for SCTP transport

- moved the sctp specific code from core to a module to make it easy to
enable/disable sctp by loading/not loading the module instead of
recompiling

Daniel-Constantin Mierla authored on 25/05/2013 07:33:39
Showing 15 changed files
... ...
@@ -155,6 +155,8 @@ endif
155 155
 
156 156
 # application server support on
157 157
 WITHAS ?= 1
158
+# enable core hooks for SCTP
159
+SCTP ?= 1
158 160
 
159 161
 # what to install
160 162
 INSTALL_FLAVOUR=$(FLAVOUR)
... ...
@@ -89,7 +89,7 @@
89 89
 #include "tcp_server.h"
90 90
 #endif
91 91
 #ifdef USE_SCTP
92
-#include "sctp_server.h"
92
+#include "sctp_core.h"
93 93
 #endif
94 94
 #include "switch.h"
95 95
 #include "events.h"
... ...
@@ -453,25 +453,6 @@ TLS_SEND_TIMEOUT	"tls_send_timeout"
453 453
 DISABLE_SCTP	"disable_sctp"
454 454
 ENABLE_SCTP	"enable_sctp"
455 455
 SCTP_CHILDREN	"sctp_children"
456
-SCTP_SOCKET_RCVBUF	"sctp_socket_rcvbuf"|"sctp_socket_receive_buffer"
457
-SCTP_SOCKET_SNDBUF	"sctp_socket_sndbuf"|"sctp_socket_send_buffer"
458
-SCTP_AUTOCLOSE	"sctp_autoclose"
459
-SCTP_SEND_TTL	"sctp_send_ttl"
460
-SCTP_SEND_RETRIES	"sctp_send_retries"
461
-SCTP_ASSOC_TRACKING	"sctp_assoc_tracking"
462
-SCTP_ASSOC_REUSE	"sctp_assoc_reuse"
463
-SCTP_MAX_ASSOCS		"sctp_max_assocs"
464
-SCTP_SRTO_INITIAL	"sctp_srto_initial"
465
-SCTP_SRTO_MAX		"sctp_srto_max"
466
-SCTP_SRTO_MIN		"sctp_srto_min"
467
-SCTP_ASOCMAXRXT		"sctp_asocmaxrxt"
468
-SCTP_INIT_MAX_ATTEMPTS		"sctp_init_max_attempts"
469
-SCTP_INIT_MAX_TIMEO			"sctp_init_max_timeo"
470
-SCTP_HBINTERVAL				"sctp_hbinterval"
471
-SCTP_PATHMAXRXT				"sctp_pathmaxrxt"
472
-SCTP_SACK_DELAY				"sctp_sack_delay"
473
-SCTP_SACK_FREQ				"sctp_sack_freq"
474
-SCTP_MAX_BURST				"sctp_max_burst"
475 456
 
476 457
 ADVERTISED_ADDRESS	"advertised_address"
477 458
 ADVERTISED_PORT		"advertised_port"
... ...
@@ -881,44 +862,6 @@ IMPORTFILE      "import_file"
881 881
 <INITIAL>{ENABLE_SCTP}	{ count(); yylval.strval=yytext; return ENABLE_SCTP;}
882 882
 <INITIAL>{SCTP_CHILDREN}	{ count(); yylval.strval=yytext;
883 883
 										return SCTP_CHILDREN; }
884
-<INITIAL>{SCTP_SOCKET_RCVBUF}	{ count(); yylval.strval=yytext;
885
-										return SCTP_SOCKET_RCVBUF; }
886
-<INITIAL>{SCTP_SOCKET_SNDBUF}	{ count(); yylval.strval=yytext;
887
-										return SCTP_SOCKET_SNDBUF; }
888
-<INITIAL>{SCTP_AUTOCLOSE}	{ count(); yylval.strval=yytext;
889
-										return SCTP_AUTOCLOSE; }
890
-<INITIAL>{SCTP_SEND_TTL}	{ count(); yylval.strval=yytext;
891
-										return SCTP_SEND_TTL; }
892
-<INITIAL>{SCTP_SEND_RETRIES}	{ count(); yylval.strval=yytext;
893
-										return SCTP_SEND_RETRIES; }
894
-<INITIAL>{SCTP_ASSOC_TRACKING}	{ count(); yylval.strval=yytext;
895
-										return SCTP_ASSOC_TRACKING; }
896
-<INITIAL>{SCTP_ASSOC_REUSE}		{ count(); yylval.strval=yytext;
897
-										return SCTP_ASSOC_REUSE; }
898
-<INITIAL>{SCTP_MAX_ASSOCS}		{ count(); yylval.strval=yytext;
899
-										return SCTP_MAX_ASSOCS; }
900
-<INITIAL>{SCTP_SRTO_INITIAL}	{ count(); yylval.strval=yytext;
901
-										return SCTP_SRTO_INITIAL; }
902
-<INITIAL>{SCTP_SRTO_MAX}	{ count(); yylval.strval=yytext;
903
-										return SCTP_SRTO_MAX; }
904
-<INITIAL>{SCTP_SRTO_MIN}	{ count(); yylval.strval=yytext;
905
-										return SCTP_SRTO_MIN; }
906
-<INITIAL>{SCTP_ASOCMAXRXT}	{ count(); yylval.strval=yytext;
907
-										return SCTP_ASOCMAXRXT; }
908
-<INITIAL>{SCTP_INIT_MAX_ATTEMPTS}	{ count(); yylval.strval=yytext;
909
-										return SCTP_INIT_MAX_ATTEMPTS; }
910
-<INITIAL>{SCTP_INIT_MAX_TIMEO}	{ count(); yylval.strval=yytext;
911
-										return SCTP_INIT_MAX_TIMEO; }
912
-<INITIAL>{SCTP_HBINTERVAL}	{ count(); yylval.strval=yytext;
913
-										return SCTP_HBINTERVAL; }
914
-<INITIAL>{SCTP_PATHMAXRXT}	{ count(); yylval.strval=yytext;
915
-										return SCTP_PATHMAXRXT; }
916
-<INITIAL>{SCTP_SACK_DELAY}	{ count(); yylval.strval=yytext;
917
-										return SCTP_SACK_DELAY; }
918
-<INITIAL>{SCTP_SACK_FREQ}	{ count(); yylval.strval=yytext;
919
-										return SCTP_SACK_FREQ; }
920
-<INITIAL>{SCTP_MAX_BURST}	{ count(); yylval.strval=yytext;
921
-										return SCTP_MAX_BURST; }
922 884
 <INITIAL>{SERVER_SIGNATURE}	{ count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
923 885
 <INITIAL>{SERVER_HEADER}	{ count(); yylval.strval=yytext; return SERVER_HEADER; }
924 886
 <INITIAL>{USER_AGENT_HEADER}	{ count(); yylval.strval=yytext; return USER_AGENT_HEADER; }
... ...
@@ -135,7 +135,7 @@
135 135
 #include "flags.h"
136 136
 #include "tcp_init.h"
137 137
 #include "tcp_options.h"
138
-#include "sctp_options.h"
138
+#include "sctp_core.h"
139 139
 #include "pvar.h"
140 140
 #include "lvalue.h"
141 141
 #include "rvalue.h"
... ...
@@ -509,25 +509,6 @@ extern char *finame;
509 509
 %token DISABLE_SCTP
510 510
 %token ENABLE_SCTP
511 511
 %token SCTP_CHILDREN
512
-%token SCTP_SOCKET_RCVBUF
513
-%token SCTP_SOCKET_SNDBUF
514
-%token SCTP_AUTOCLOSE
515
-%token SCTP_SEND_TTL
516
-%token SCTP_SEND_RETRIES
517
-%token SCTP_ASSOC_TRACKING
518
-%token SCTP_ASSOC_REUSE
519
-%token SCTP_MAX_ASSOCS
520
-%token SCTP_SRTO_INITIAL
521
-%token SCTP_SRTO_MAX
522
-%token SCTP_SRTO_MIN
523
-%token SCTP_ASOCMAXRXT
524
-%token SCTP_INIT_MAX_ATTEMPTS
525
-%token SCTP_INIT_MAX_TIMEO
526
-%token SCTP_HBINTERVAL
527
-%token SCTP_PATHMAXRXT
528
-%token SCTP_SACK_DELAY
529
-%token SCTP_SACK_FREQ
530
-%token SCTP_MAX_BURST
531 512
 %token ADVERTISED_ADDRESS
532 513
 %token ADVERTISED_PORT
533 514
 %token DISABLE_CORE
... ...
@@ -1408,122 +1389,6 @@ assign_stm:
1408 1408
 		#endif
1409 1409
 	}
1410 1410
 	| SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1411
-	| SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1412
-		#ifdef USE_SCTP
1413
-			sctp_default_cfg.so_rcvbuf=$3;
1414
-		#else
1415
-			warn("sctp support not compiled in");
1416
-		#endif
1417
-	}
1418
-	| SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1419
-	| SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1420
-		#ifdef USE_SCTP
1421
-			sctp_default_cfg.so_sndbuf=$3;
1422
-		#else
1423
-			warn("sctp support not compiled in");
1424
-		#endif
1425
-	}
1426
-	| SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1427
-	| SCTP_AUTOCLOSE EQUAL NUMBER {
1428
-		#ifdef USE_SCTP
1429
-			sctp_default_cfg.autoclose=$3;
1430
-		#else
1431
-			warn("sctp support not compiled in");
1432
-		#endif
1433
-	}
1434
-	| SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1435
-	| SCTP_SEND_TTL EQUAL NUMBER {
1436
-		#ifdef USE_SCTP
1437
-			sctp_default_cfg.send_ttl=$3;
1438
-		#else
1439
-			warn("sctp support not compiled in");
1440
-		#endif
1441
-	}
1442
-	| SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1443
-	| SCTP_SEND_RETRIES EQUAL NUMBER {
1444
-		#ifdef USE_SCTP
1445
-			sctp_default_cfg.send_retries=$3;
1446
-		#else
1447
-			warn("sctp support not compiled in");
1448
-		#endif
1449
-	}
1450
-	| SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1451
-	| SCTP_ASSOC_TRACKING EQUAL NUMBER {
1452
-		#ifdef USE_SCTP
1453
-			#ifdef SCTP_CONN_REUSE
1454
-				sctp_default_cfg.assoc_tracking=$3;
1455
-			#else
1456
-				if ($3)
1457
-					warn("sctp association tracking/reuse (SCTP_CONN_REUSE) "
1458
-							"support not compiled in");
1459
-			#endif /* SCTP_CONN_REUSE */
1460
-		#else
1461
-			warn("sctp support not compiled in");
1462
-		#endif /* USE_SCTP */
1463
-	}
1464
-	| SCTP_ASSOC_TRACKING EQUAL error { yyerror("number expected"); }
1465
-	| SCTP_ASSOC_REUSE EQUAL NUMBER {
1466
-		#ifdef USE_SCTP
1467
-			#ifdef SCTP_CONN_REUSE
1468
-				sctp_default_cfg.assoc_reuse=$3;
1469
-			#else
1470
-				if ($3)
1471
-					warn("sctp association reuse (SCTP_CONN_REUSE) support"
1472
-							" not compiled in");
1473
-			#endif /* SCTP_CONN_REUSE */
1474
-		#else
1475
-			warn("sctp support not compiled in");
1476
-		#endif /* USE_SCTP */
1477
-	}
1478
-	| SCTP_ASSOC_REUSE EQUAL error { yyerror("number expected"); }
1479
-	| SCTP_MAX_ASSOCS EQUAL intno {
1480
-			IF_SCTP(sctp_default_cfg.max_assocs=$3);
1481
-	}
1482
-	| SCTP_MAX_ASSOCS EQUAL error { yyerror("number expected"); }
1483
-	| SCTP_SRTO_INITIAL EQUAL NUMBER {
1484
-			IF_SCTP(sctp_default_cfg.srto_initial=$3);
1485
-	}
1486
-	| SCTP_SRTO_INITIAL EQUAL error { yyerror("number expected"); }
1487
-	| SCTP_SRTO_MAX EQUAL NUMBER {
1488
-			IF_SCTP(sctp_default_cfg.srto_max=$3);
1489
-	}
1490
-	| SCTP_SRTO_MAX EQUAL error { yyerror("number expected"); }
1491
-	| SCTP_SRTO_MIN EQUAL NUMBER {
1492
-			IF_SCTP(sctp_default_cfg.srto_min=$3);
1493
-	}
1494
-	| SCTP_SRTO_MIN EQUAL error { yyerror("number expected"); }
1495
-	| SCTP_ASOCMAXRXT EQUAL NUMBER {
1496
-			IF_SCTP(sctp_default_cfg.asocmaxrxt=$3);
1497
-	}
1498
-	| SCTP_ASOCMAXRXT EQUAL error { yyerror("number expected"); }
1499
-	| SCTP_INIT_MAX_ATTEMPTS EQUAL NUMBER {
1500
-			IF_SCTP(sctp_default_cfg.init_max_attempts=$3);
1501
-	}
1502
-	| SCTP_INIT_MAX_ATTEMPTS EQUAL error { yyerror("number expected"); }
1503
-	| SCTP_INIT_MAX_TIMEO EQUAL NUMBER {
1504
-			IF_SCTP(sctp_default_cfg.init_max_timeo=$3);
1505
-	}
1506
-	| SCTP_INIT_MAX_TIMEO EQUAL error { yyerror("number expected"); }
1507
-	| SCTP_HBINTERVAL EQUAL intno {
1508
-			IF_SCTP(sctp_default_cfg.hbinterval=$3);
1509
-	}
1510
-	| SCTP_HBINTERVAL EQUAL error { yyerror("number expected"); }
1511
-	| SCTP_PATHMAXRXT EQUAL NUMBER {
1512
-			IF_SCTP(sctp_default_cfg.pathmaxrxt=$3);
1513
-	}
1514
-	| SCTP_PATHMAXRXT EQUAL error { yyerror("number expected"); }
1515
-	| SCTP_SACK_DELAY EQUAL NUMBER {
1516
-			IF_SCTP(sctp_default_cfg.sack_delay=$3);
1517
-	}
1518
-	| SCTP_SACK_DELAY EQUAL error { yyerror("number expected"); }
1519
-	| SCTP_SACK_FREQ EQUAL NUMBER {
1520
-			IF_SCTP(sctp_default_cfg.sack_freq=$3);
1521
-	}
1522
-	| SCTP_SACK_FREQ EQUAL error { yyerror("number expected"); }
1523
-	| SCTP_MAX_BURST EQUAL NUMBER {
1524
-			IF_SCTP(sctp_default_cfg.max_burst=$3);
1525
-	}
1526
-	| SCTP_MAX_BURST EQUAL error { yyerror("number expected"); }
1527 1411
 	| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1528 1412
 	| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1529 1413
 	| SERVER_HEADER EQUAL STRING { server_hdr.s=$3;
... ...
@@ -3065,80 +2930,35 @@ cmd:
3065 3065
 	| FORWARD_TLS LPAREN error RPAREN { $$=0; 
3066 3066
 									yyerror("bad forward_tls argument"); }
3067 3067
 	| FORWARD_SCTP LPAREN host RPAREN {
3068
-		#ifdef USE_SCTP
3069 3068
 			$$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3070
-		#else
3071
-			$$=0;
3072
-			yyerror("sctp support not compiled in");
3073
-		#endif
3074 3069
 	}
3075 3070
 	| FORWARD_SCTP LPAREN STRING RPAREN {
3076
-		#ifdef USE_SCTP
3077 3071
 			$$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3078
-		#else
3079
-			$$=0;
3080
-			yyerror("sctp support not compiled in");
3081
-		#endif
3082 3072
 	}
3083 3073
 	| FORWARD_SCTP LPAREN ip RPAREN	{
3084
-		#ifdef USE_SCTP
3085 3074
 			$$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
3086
-		#else
3087
-			$$=0;
3088
-			yyerror("sctp support not compiled in");
3089
-		#endif
3090 3075
 	}
3091 3076
 	| FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
3092
-		#ifdef USE_SCTP
3093 3077
 			$$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
3094 3078
 							(void*)$5); set_cfg_pos($$);
3095
-		#else
3096
-			$$=0;
3097
-			yyerror("sctp support not compiled in");
3098
-		#endif
3099 3079
 	}
3100 3080
 	| FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
3101
-		#ifdef USE_SCTP
3102 3081
 			$$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
3103 3082
 							(void*)$5); set_cfg_pos($$);
3104
-		#else
3105
-			$$=0;
3106
-			yyerror("sctp support not compiled in");
3107
-		#endif
3108 3083
 	}
3109 3084
 	| FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
3110
-		#ifdef USE_SCTP
3111 3085
 			$$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 
3112 3086
 							(void*)$5); set_cfg_pos($$);
3113
-		#else
3114
-			$$=0;
3115
-			yyerror("sctp support not compiled in");
3116
-		#endif
3117 3087
 					}
3118 3088
 	| FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
3119
-		#ifdef USE_SCTP
3120 3089
 			$$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
3121
-		#else
3122
-			$$=0;
3123
-			yyerror("sctp support not compiled in");
3124
-		#endif
3125 3090
 	}
3126 3091
 	| FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
3127
-		#ifdef USE_SCTP
3128 3092
 			$$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
3129 3093
 							(void*)$5); set_cfg_pos($$);
3130
-		#else
3131
-			$$=0;
3132
-			yyerror("sctp support not compiled in");
3133
-		#endif
3134 3094
 	}
3135 3095
 	| FORWARD_SCTP LPAREN URIHOST RPAREN {
3136
-		#ifdef USE_SCTP
3137 3096
 			$$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
3138
-		#else
3139
-			$$=0;
3140
-			yyerror("tls support not compiled in");
3141
-		#endif
3142 3097
 	}
3143 3098
 	| FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
3144 3099
 	| FORWARD_SCTP LPAREN error RPAREN { $$=0; 
... ...
@@ -47,10 +47,6 @@
47 47
 #include "tcp_options.h"
48 48
 #include "core_cmd.h"
49 49
 #include "cfg_core.h"
50
-#ifdef USE_SCTP
51
-#include "sctp_options.h"
52
-#include "sctp_server.h"
53
-#endif
54 50
 
55 51
 #ifdef USE_DNS_CACHE
56 52
 void dns_cache_debug(rpc_t* rpc, void* ctx);
... ...
@@ -834,133 +830,6 @@ static void core_tcp_list(rpc_t* rpc, void* c)
834 834
 }
835 835
 
836 836
 
837
-
838
-static const char* core_sctp_options_doc[] = {
839
-	"Returns active sctp options. With one parameter"
840
-	" it returns the sctp options set in the kernel for a specific socket"
841
-	"(debugging), with 0 filled in for non-kernel related options."
842
-	" The parameter can be: \"default\" | \"first\" | address[:port] ."
843
-	" With no parameters it returns ser's idea of the current sctp options"
844
-	 " (intended non-debugging use).",
845
-	/* Documentation string */
846
-	0                                 /* Method signature(s) */
847
-};
848
-
849
-static void core_sctp_options(rpc_t* rpc, void* c)
850
-{
851
-#ifdef USE_SCTP
852
-	void *handle;
853
-	struct cfg_group_sctp t;
854
-	char* param;
855
-	struct socket_info* si;
856
-	char* host;
857
-	str hs;
858
-	int hlen;
859
-	int port;
860
-	int proto;
861
-
862
-	param=0;
863
-	if (!sctp_disable){
864
-		/* look for optional socket parameter */
865
-		if (rpc->scan(c, "*s", &param)>0){
866
-			si=0;
867
-			if (strcasecmp(param, "default")==0){
868
-				si=sendipv4_sctp?sendipv4_sctp:sendipv6_sctp;
869
-			}else if (strcasecmp(param, "first")==0){
870
-				si=sctp_listen;
871
-			}else{
872
-				if (parse_phostport(param, &host, &hlen, &port, &proto)!=0){
873
-					rpc->fault(c, 500, "bad param (use address, address:port,"
874
-										" default or first)");
875
-					return;
876
-				}
877
-				if (proto && proto!=PROTO_SCTP){
878
-					rpc->fault(c, 500, "bad protocol in param (only SCTP"
879
-										" allowed)");
880
-					return;
881
-				}
882
-				hs.s=host;
883
-				hs.len=hlen;
884
-				si=grep_sock_info(&hs, port, PROTO_SCTP);
885
-				if (si==0){
886
-					rpc->fault(c, 500, "not listening on sctp %s", param);
887
-					return;
888
-				}
889
-			}
890
-			if (si==0 || si->socket==-1){
891
-				rpc->fault(c, 500, "could not find a sctp socket");
892
-				return;
893
-			}
894
-			memset(&t, 0, sizeof(t));
895
-			if (sctp_get_cfg_from_sock(si->socket, &t)!=0){
896
-				rpc->fault(c, 500, "failed to get socket options");
897
-				return;
898
-			}
899
-		}else{
900
-			sctp_options_get(&t);
901
-		}
902
-		rpc->add(c, "{", &handle);
903
-		rpc->struct_add(handle, "ddddddddddddddddddd",
904
-			"sctp_socket_rcvbuf",	t.so_rcvbuf,
905
-			"sctp_socket_sndbuf",	t.so_sndbuf,
906
-			"sctp_autoclose",		t.autoclose,
907
-			"sctp_send_ttl",	t.send_ttl,
908
-			"sctp_send_retries",	t.send_retries,
909
-			"sctp_assoc_tracking",	t.assoc_tracking,
910
-			"sctp_assoc_reuse",	t.assoc_reuse,
911
-			"sctp_max_assocs", t.max_assocs,
912
-			"sctp_srto_initial",	t.srto_initial,
913
-			"sctp_srto_max",		t.srto_max,
914
-			"sctp_srto_min",		t.srto_min,
915
-			"sctp_asocmaxrxt",	t.asocmaxrxt,
916
-			"sctp_init_max_attempts",	t.init_max_attempts,
917
-			"sctp_init_max_timeo",t.init_max_timeo,
918
-			"sctp_hbinterval",	t.hbinterval,
919
-			"sctp_pathmaxrxt",	t.pathmaxrxt,
920
-			"sctp_sack_delay",	t.sack_delay,
921
-			"sctp_sack_freq",	t.sack_freq,
922
-			"sctp_max_burst",	t.max_burst
923
-		);
924
-	}else{
925
-		rpc->fault(c, 500, "sctp support disabled");
926
-	}
927
-#else
928
-	rpc->fault(c, 500, "sctp support not compiled");
929
-#endif
930
-}
931
-
932
-
933
-
934
-static const char* core_sctpinfo_doc[] = {
935
-	"Returns sctp related info.",    /* Documentation string */
936
-	0                               /* Method signature(s) */
937
-};
938
-
939
-static void core_sctpinfo(rpc_t* rpc, void* c)
940
-{
941
-#ifdef USE_SCTP
942
-	void *handle;
943
-	struct sctp_gen_info i;
944
-
945
-	if (!sctp_disable){
946
-		sctp_get_info(&i);
947
-		rpc->add(c, "{", &handle);
948
-		rpc->struct_add(handle, "ddd",
949
-			"opened_connections", i.sctp_connections_no,
950
-			"tracked_connections", i.sctp_tracked_no,
951
-			"total_connections", i.sctp_total_connections
952
-		);
953
-	}else{
954
-		rpc->fault(c, 500, "sctp support disabled");
955
-	}
956
-#else
957
-	rpc->fault(c, 500, "sctp support not compiled");
958
-#endif
959
-}
960
-
961
-
962
-
963
-
964 837
 static const char* core_udp4rawinfo_doc[] = {
965 838
 	"Returns udp4_raw related info.",    /* Documentation string */
966 839
 	0                                     /* Method signature(s) */
... ...
@@ -1106,9 +975,6 @@ static rpc_export_t core_rpc_methods[] = {
1106 1106
 	{"core.tcp_info",          core_tcpinfo,           core_tcpinfo_doc,    0},
1107 1107
 	{"core.tcp_options",       core_tcp_options,       core_tcp_options_doc,0},
1108 1108
 	{"core.tcp_list",          core_tcp_list,          core_tcp_list_doc,0},
1109
-	{"core.sctp_options",      core_sctp_options,      core_sctp_options_doc,
1110
-		0},
1111
-	{"core.sctp_info",         core_sctpinfo,          core_sctpinfo_doc,   0},
1112 1109
 	{"core.udp4_raw_info",     core_udp4rawinfo,       core_udp4rawinfo_doc,
1113 1110
 		0},
1114 1111
 	{"core.aliases_list",      core_aliases_list,      core_aliases_list_doc,   0},
... ...
@@ -57,7 +57,7 @@
57 57
 #include "tcp_conn.h"
58 58
 #endif
59 59
 #ifdef USE_SCTP
60
-#include "sctp_server.h"
60
+#include "sctp_core.h"
61 61
 #endif
62 62
 
63 63
 #include "compiler_opt.h"
... ...
@@ -258,7 +258,7 @@ static inline int msg_send(struct dest_info* dst, char* buf, int len)
258 258
 				}
259 259
 				dst=&new_dst;
260 260
 			}
261
-			if (unlikely(sctp_msg_send(dst, outb.s, outb.len)<0)){
261
+			if (unlikely(sctp_core_msg_send(dst, outb.s, outb.len)<0)){
262 262
 				STATS_TX_DROPS;
263 263
 				LOG(L_ERR, "msg_send: ERROR: sctp_msg_send failed\n");
264 264
 				goto error;
... ...
@@ -162,8 +162,7 @@
162 162
 #endif /* CORE_TLS */
163 163
 #endif /* USE_TCP */
164 164
 #ifdef USE_SCTP
165
-#include "sctp_options.h"
166
-#include "sctp_server.h"
165
+#include "sctp_core.h"
167 166
 #endif
168 167
 #include "usr_avp.h"
169 168
 #include "rpc_lookup.h"
... ...
@@ -582,7 +581,7 @@ void cleanup(show_status)
582 582
 #endif /* USE_TLS */
583 583
 #endif /* USE_TCP */
584 584
 #ifdef USE_SCTP
585
-	destroy_sctp();
585
+	sctp_core_destroy();
586 586
 #endif
587 587
 	destroy_timer();
588 588
 	pv_destroy_api();
... ...
@@ -1491,7 +1490,7 @@ int main_loop(void)
1491 1491
 #ifdef USE_SCTP
1492 1492
 		if (!sctp_disable){
1493 1493
 			for(si=sctp_listen; si; si=si->next){
1494
-				if (sctp_init_sock(si)==-1)  goto error;
1494
+				if (sctp_core_init_sock(si)==-1)  goto error;
1495 1495
 				/* get first ipv4/ipv6 socket*/
1496 1496
 				if ((si->address.af==AF_INET) &&
1497 1497
 						((sendipv4_sctp==0) ||
... ...
@@ -1646,7 +1645,7 @@ int main_loop(void)
1646 1646
 #ifdef STATS
1647 1647
 						setstats( i+r*children_no );
1648 1648
 #endif
1649
-						return sctp_rcv_loop();
1649
+						return sctp_core_rcv_loop();
1650 1650
 					}
1651 1651
 				}
1652 1652
 			/*parent*/
... ...
@@ -1903,7 +1902,7 @@ int main(int argc, char** argv)
1903 1903
 	init_tcp_options(); /* set the defaults before the config */
1904 1904
 #endif
1905 1905
 #ifdef USE_SCTP
1906
-	init_sctp_options(); /* set defaults before the config */
1906
+	sctp_core_init_options(); /* set defaults before the config */
1907 1907
 #endif
1908 1908
 	/* process command line (cfg. file path etc) */
1909 1909
 	optind = 1;  /* reset getopt */
... ...
@@ -1944,7 +1943,7 @@ int main(int argc, char** argv)
1944 1944
 					print_ct_constants();
1945 1945
 #ifdef USE_SCTP
1946 1946
 					tmp=malloc(256);
1947
-					if (tmp && (sctp_check_compiled_sockopts(tmp, 256)!=0))
1947
+					if (tmp && (sctp_core_check_compiled_sockopts(tmp, 256)!=0))
1948 1948
 						printf("sctp unsupported socket options: %s\n", tmp);
1949 1949
 					if (tmp) free(tmp);
1950 1950
 #endif
... ...
@@ -2282,7 +2281,7 @@ try_again:
2282 2282
 #ifdef USE_SCTP
2283 2283
 	if (sctp_disable!=1){
2284 2284
 		/* fix it */
2285
-		if (sctp_check_support()==-1){
2285
+		if (sctp_core_check_support()==-1){
2286 2286
 			/* check if sctp support is auto, if not warn about disabling it */
2287 2287
 			if (sctp_disable!=2){
2288 2288
 				fprintf(stderr, "ERROR: " "sctp enabled, but not supported by"
... ...
@@ -2403,12 +2402,6 @@ try_again:
2403 2403
 		goto error;
2404 2404
 	}
2405 2405
 #endif /* USE_TCP */
2406
-#ifdef USE_SCTP
2407
-	if (sctp_register_cfg()){
2408
-		LOG(L_CRIT, "could not register the sctp configuration\n");
2409
-		goto error;
2410
-	}
2411
-#endif /* USE_SCTP */
2412 2406
 	/*init timer, before parsing the cfg!*/
2413 2407
 	if (init_timer()<0){
2414 2408
 		LOG(L_CRIT, "could not initialize timer, exiting...\n");
... ...
@@ -2454,7 +2447,7 @@ try_again:
2454 2454
 #endif /* USE_TCP */
2455 2455
 #ifdef USE_SCTP
2456 2456
 	if (!sctp_disable){
2457
-		if (init_sctp()<0){
2457
+		if (sctp_core_init()<0){
2458 2458
 			LOG(L_CRIT, "Could not initialize sctp, exiting...\n");
2459 2459
 			goto error;
2460 2460
 		}
2461 2461
similarity index 100%
2462 2462
rename from sctp_ev.h
2463 2463
rename to modules/sctp/sctp_ev.h
2464 2464
similarity index 100%
2465 2465
rename from sctp_options.c
2466 2466
rename to modules/sctp/sctp_options.c
2467 2467
similarity index 100%
2468 2468
rename from sctp_options.h
2469 2469
rename to modules/sctp/sctp_options.h
2470 2470
similarity index 100%
2471 2471
rename from sctp_server.c
2472 2472
rename to modules/sctp/sctp_server.c
2473 2473
similarity index 100%
2474 2474
rename from sctp_server.h
2475 2475
rename to modules/sctp/sctp_server.h
2476 2476
similarity index 100%
2477 2477
rename from sctp_sockopts.h
2478 2478
rename to modules/sctp/sctp_sockopts.h
2479 2479
similarity index 100%
2480 2480
rename from sctp_stats.c
2481 2481
rename to modules/sctp/sctp_stats.c
2482 2482
similarity index 100%
2483 2483
rename from sctp_stats.h
2484 2484
rename to modules/sctp/sctp_stats.h