Beispiel #1
0
static void core_sctp_options(rpc_t* rpc, void* c)
{
#ifdef USE_SCTP
	void *handle;
	struct cfg_group_sctp t;

	if (!sctp_disable){
		sctp_options_get(&t);
		rpc->add(c, "{", &handle);
		rpc->struct_add(handle, "ddddddddddddddddddd",
			"sctp_socket_rcvbuf",	t.so_rcvbuf,
			"sctp_socket_sndbuf",	t.so_sndbuf,
			"sctp_autoclose",		t.autoclose,
			"sctp_send_ttl",	t.send_ttl,
			"sctp_send_retries",	t.send_retries,
			"sctp_assoc_tracking",	t.assoc_tracking,
			"sctp_assoc_reuse",	t.assoc_reuse,
			"sctp_max_assocs", t.max_assocs,
			"sctp_srto_initial",	t.srto_initial,
			"sctp_srto_max",		t.srto_max,
			"sctp_srto_min",		t.srto_min,
			"sctp_asocmaxrxt",	t.asocmaxrxt,
			"sctp_init_max_attempts",	t.init_max_attempts,
			"sctp_init_max_timeo",t.init_max_timeo,
			"sctp_hbinterval",	t.hbinterval,
			"sctp_pathmaxrxt",	t.pathmaxrxt,
			"sctp_sack_delay",	t.sack_delay,
			"sctp_sack_freq",	t.sack_freq,
			"sctp_max_burst",	t.max_burst
		);
	}else{
		rpc->fault(c, 500, "sctp support disabled");
	}
#else
	rpc->fault(c, 500, "sctp support not compiled");
#endif
}
Beispiel #2
0
static void core_sctp_options(rpc_t *rpc, void *c)
{
#ifdef USE_SCTP
	void *handle;
	struct cfg_group_sctp t;
	char *param;
	struct socket_info *si;
	char *host;
	str hs;
	int hlen;
	int port;
	int proto;

	param = 0;
	if(!sctp_disable) {
		/* look for optional socket parameter */
		if(rpc->scan(c, "*s", &param) > 0) {
			si = 0;
			if(strcasecmp(param, "default") == 0) {
				si = sendipv4_sctp ? sendipv4_sctp : sendipv6_sctp;
			} else if(strcasecmp(param, "first") == 0) {
				si = sctp_listen;
			} else {
				if(parse_phostport(param, &host, &hlen, &port, &proto) != 0) {
					rpc->fault(c, 500, "bad param (use address, address:port,"
									   " default or first)");
					return;
				}
				if(proto && proto != PROTO_SCTP) {
					rpc->fault(c, 500, "bad protocol in param (only SCTP"
									   " allowed)");
					return;
				}
				hs.s = host;
				hs.len = hlen;
				si = grep_sock_info(&hs, port, PROTO_SCTP);
				if(si == 0) {
					rpc->fault(c, 500, "not listening on sctp %s", param);
					return;
				}
			}
			if(si == 0 || si->socket == -1) {
				rpc->fault(c, 500, "could not find a sctp socket");
				return;
			}
			memset(&t, 0, sizeof(t));
			if(sctp_get_cfg_from_sock(si->socket, &t) != 0) {
				rpc->fault(c, 500, "failed to get socket options");
				return;
			}
		} else {
			sctp_options_get(&t);
		}
		rpc->add(c, "{", &handle);
		rpc->struct_add(handle, "ddddddddddddddddddd", "sctp_socket_rcvbuf",
				t.so_rcvbuf, "sctp_socket_sndbuf", t.so_sndbuf,
				"sctp_autoclose", t.autoclose, "sctp_send_ttl", t.send_ttl,
				"sctp_send_retries", t.send_retries, "sctp_assoc_tracking",
				t.assoc_tracking, "sctp_assoc_reuse", t.assoc_reuse,
				"sctp_max_assocs", t.max_assocs, "sctp_srto_initial",
				t.srto_initial, "sctp_srto_max", t.srto_max, "sctp_srto_min",
				t.srto_min, "sctp_asocmaxrxt", t.asocmaxrxt,
				"sctp_init_max_attempts", t.init_max_attempts,
				"sctp_init_max_timeo", t.init_max_timeo, "sctp_hbinterval",
				t.hbinterval, "sctp_pathmaxrxt", t.pathmaxrxt,
				"sctp_sack_delay", t.sack_delay, "sctp_sack_freq", t.sack_freq,
				"sctp_max_burst", t.max_burst);
	} else {
		rpc->fault(c, 500, "sctp support disabled");
	}
#else
	rpc->fault(c, 500, "sctp support not compiled");
#endif
}