Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/sctp_module.c
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
#include "opt_inet.h" | |||||
markj: The file is missing a license header. | |||||
#include "opt_inet6.h" | |||||
#include <sys/param.h> | |||||
#include <sys/kernel.h> | |||||
Not Done Inline Actionsnow 2020 emaste: now 2020 | |||||
#include <sys/module.h> | |||||
#include <sys/protosw.h> | |||||
#include <sys/socket.h> | |||||
#include <netinet/in.h> | |||||
#include <netinet/ip.h> | |||||
#include <netinet/ip_var.h> | |||||
#include <netinet/sctp.h> | |||||
#include <netinet/sctp_pcb.h> | |||||
#include <netinet/sctp_var.h> | |||||
#include <netinet/sctp_os_bsd.h> | |||||
#include <netinet6/ip6_var.h> | |||||
#include <netinet6/sctp6_var.h> | |||||
#ifdef INET | |||||
extern struct domain inetdomain; | |||||
struct protosw sctp_stream_protosw = { | |||||
.pr_type = SOCK_STREAM, | |||||
.pr_domain = &inetdomain, | |||||
.pr_protocol = IPPROTO_SCTP, | |||||
.pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, | |||||
.pr_input = sctp_input, | |||||
.pr_ctlinput = sctp_ctlinput, | |||||
.pr_ctloutput = sctp_ctloutput, | |||||
.pr_drain = sctp_drain, | |||||
.pr_usrreqs = &sctp_usrreqs, | |||||
}; | |||||
struct protosw sctp_seqpacket_protosw = { | |||||
.pr_type = SOCK_SEQPACKET, | |||||
.pr_domain = &inetdomain, | |||||
.pr_protocol = IPPROTO_SCTP, | |||||
.pr_flags = PR_WANTRCVD|PR_LASTHDR, | |||||
.pr_input = sctp_input, | |||||
.pr_ctlinput = sctp_ctlinput, | |||||
.pr_ctloutput = sctp_ctloutput, | |||||
.pr_drain = sctp_drain, | |||||
.pr_usrreqs = &sctp_usrreqs, | |||||
}; | |||||
#endif | |||||
#ifdef INET6 | |||||
extern struct domain inet6domain; | |||||
struct protosw sctp6_stream_protosw = { | |||||
.pr_type = SOCK_STREAM, | |||||
.pr_domain = &inet6domain, | |||||
.pr_protocol = IPPROTO_SCTP, | |||||
.pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, | |||||
.pr_input = sctp6_input, | |||||
.pr_ctlinput = sctp6_ctlinput, | |||||
.pr_ctloutput = sctp_ctloutput, | |||||
.pr_drain = sctp_drain, | |||||
.pr_usrreqs = &sctp6_usrreqs, | |||||
}; | |||||
struct protosw sctp6_seqpacket_protosw = { | |||||
.pr_type = SOCK_SEQPACKET, | |||||
.pr_domain = &inet6domain, | |||||
.pr_protocol = IPPROTO_SCTP, | |||||
.pr_flags = PR_WANTRCVD|PR_LASTHDR, | |||||
.pr_input = sctp6_input, | |||||
.pr_ctlinput = sctp6_ctlinput, | |||||
.pr_ctloutput = sctp_ctloutput, | |||||
.pr_drain = sctp_drain, | |||||
.pr_usrreqs = &sctp6_usrreqs, | |||||
}; | |||||
markjAuthorUnsubmitted Not Done Inline ActionsExtra newline. markj: Extra newline. | |||||
#endif | |||||
static int | |||||
sctp_module_load(void) | |||||
{ | |||||
int error; | |||||
sctp_init(); | |||||
#ifdef INET | |||||
error = pf_proto_register(PF_INET, &sctp_stream_protosw); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_register(PF_INET, &sctp_seqpacket_protosw); | |||||
if (error != 0) | |||||
return (error); | |||||
error = ipproto_register(IPPROTO_SCTP); | |||||
if (error != 0) | |||||
/* XXX do we need to unwind? */ | |||||
markjAuthorUnsubmitted Not Done Inline ActionsI think we could address this by keeping a set of 4 global flags which indicate whether the protocol tuple <socket type, domain> has been registered. Then we conditionalize deregistration on those flags. markj: I think we could address this by keeping a set of 4 global flags which indicate whether the… | |||||
return (error); | |||||
#endif | |||||
#ifdef INET6 | |||||
error = pf_proto_register(PF_INET6, &sctp6_stream_protosw); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_register(PF_INET6, &sctp6_seqpacket_protosw); | |||||
if (error != 0) | |||||
return (error); | |||||
error = ip6proto_register(IPPROTO_SCTP); | |||||
if (error != 0) | |||||
/* XXX do we need to unwind? */ | |||||
return (error); | |||||
#endif | |||||
return (0); | |||||
} | |||||
static int | |||||
sctp_module_unload(void) | |||||
{ | |||||
int error; | |||||
EVENTHANDLER_DEREGISTER(rt_addrmsg, SCTP_BASE_VAR(eh_tag)); | |||||
error = ipproto_unregister(IPPROTO_SCTP); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_unregister(PF_INET, IPPROTO_SCTP, SOCK_STREAM); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_unregister(PF_INET, IPPROTO_SCTP, SOCK_SEQPACKET); | |||||
if (error != 0) | |||||
return (error); | |||||
#ifdef INET6 | |||||
error = ip6proto_unregister(IPPROTO_SCTP); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_unregister(PF_INET6, IPPROTO_SCTP, SOCK_STREAM); | |||||
if (error != 0) | |||||
return (error); | |||||
error = pf_proto_unregister(PF_INET6, IPPROTO_SCTP, SOCK_SEQPACKET); | |||||
if (error != 0) | |||||
return (error); | |||||
#endif | |||||
return (sctp_syscalls_uninit()); | |||||
} | |||||
static int | |||||
sctp_modload(struct module *module, int cmd, void *arg) | |||||
{ | |||||
int error; | |||||
switch (cmd) { | |||||
case MOD_LOAD: | |||||
error = sctp_module_load(); | |||||
break; | |||||
case MOD_UNLOAD: | |||||
error = sctp_module_unload(); | |||||
break; | |||||
default: | |||||
error = 0; | |||||
break; | |||||
} | |||||
return (error); | |||||
} | |||||
static moduledata_t sctp_mod = { | |||||
"sctp", | |||||
&sctp_modload, | |||||
NULL, | |||||
}; | |||||
DECLARE_MODULE(sctp, sctp_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); | |||||
MODULE_VERSION(sctp, 1); |
The file is missing a license header.