diff options
-rwxr-xr-x | netinet/sctp_output.c | 8 | ||||
-rwxr-xr-x | netinet/sctp_pcb.c | 60 | ||||
-rwxr-xr-x | netinet/sctp_pcb.h | 9 | ||||
-rwxr-xr-x | netinet/sctp_structs.h | 3 | ||||
-rwxr-xr-x | netinet/sctp_timer.h | 7 | ||||
-rwxr-xr-x | netinet/sctp_uio.h | 2 | ||||
-rwxr-xr-x | netinet/sctp_usrreq.c | 46 | ||||
-rwxr-xr-x | netinet/sctp_var.h | 6 | ||||
-rw-r--r-- | netinet6/sctp6_usrreq.c | 40 |
9 files changed, 112 insertions, 69 deletions
diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index dac5a29..aef8c8a 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -4349,7 +4349,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * This means especially, that it is not set at the * SCTP layer. So use the value from the IP layer. */ +#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) + flowlabel = ntohl(inp->ip_inp.inp.inp_flow); +#else flowlabel = ntohl(((struct in6pcb *)inp)->in6p_flowinfo); +#endif } flowlabel &= 0x000fffff; len = sizeof(struct ip6_hdr) + sizeof(struct sctphdr); @@ -4429,8 +4433,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * SCTP layer. So use the value from the IP layer. */ #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) + tos_value = (ntohl(inp->ip_inp.inp.inp_flow) >> 20) & 0xff; +#else tos_value = (ntohl(((struct in6pcb *)inp)->in6p_flowinfo) >> 20) & 0xff; #endif +#endif } tos_value &= 0xfc; if (ecn_ok) { diff --git a/netinet/sctp_pcb.c b/netinet/sctp_pcb.c index e4c25bd..052b7bb 100755 --- a/netinet/sctp_pcb.c +++ b/netinet/sctp_pcb.c @@ -2877,7 +2877,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) #if defined(__APPLE__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) - inp->ip_inp.inp.inpcb_mtx = lck_mtx_alloc_init(SCTP_BASE_INFO(mtx_grp), SCTP_BASE_INFO(mtx_attr)); + inp->ip_inp.inp.inpcb_mtx = lck_mtx_alloc_init(SCTP_BASE_INFO(sctbinfo).mtx_grp, SCTP_BASE_INFO(sctbinfo).mtx_attr); if (inp->ip_inp.inp.inpcb_mtx == NULL) { SCTP_PRINTF("in_pcballoc: can't alloc mutex! so=%p\n", (void *)so); #ifdef SCTP_MVRF @@ -2886,12 +2886,14 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark); so->so_pcb = NULL; SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); - SCTP_UNLOCK_EXC(SCTP_BASE_INFO(ipi_ep_mtx)); + SCTP_UNLOCK_EXC(SCTP_BASE_INFO(sctbinfo).ipi_lock); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM); return (ENOMEM); } +#elif defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) + lck_mtx_init(&inp->ip_inp.inp.inpcb_mtx, SCTP_BASE_INFO(sctbinfo).mtx_grp, SCTP_BASE_INFO(sctbinfo).mtx_attr); #else - lck_mtx_init(&inp->ip_inp.inp.inpcb_mtx, SCTP_BASE_INFO(mtx_grp), SCTP_BASE_INFO(mtx_attr)); + lck_mtx_init(&inp->ip_inp.inp.inpcb_mtx, SCTP_BASE_INFO(sctbinfo).ipi_lock_grp, SCTP_BASE_INFO(sctbinfo).ipi_lock_attr); #endif #endif SCTP_INP_INFO_WLOCK(); @@ -2907,7 +2909,12 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) /* add it to the info area */ LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list); #if defined(__APPLE__) - LIST_INSERT_HEAD(&SCTP_BASE_INFO(inplisthead), &inp->ip_inp.inp, inp_list); + inp->ip_inp.inp.inp_pcbinfo = &SCTP_BASE_INFO(sctbinfo); +#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) + LIST_INSERT_HEAD(SCTP_BASE_INFO(sctbinfo).listhead, &inp->ip_inp.inp, inp_list); +#else + LIST_INSERT_HEAD(SCTP_BASE_INFO(sctbinfo).ipi_listhead, &inp->ip_inp.inp, inp_list); +#endif #endif SCTP_INP_INFO_WUNLOCK(); @@ -6615,6 +6622,25 @@ sctp_pcb_init() LIST_INIT(&SCTP_BASE_INFO(listhead)); #if defined(__APPLE__) LIST_INIT(&SCTP_BASE_INFO(inplisthead)); +#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) + SCTP_BASE_INFO(sctbinfo).listhead = &SCTP_BASE_INFO(inplisthead); + SCTP_BASE_INFO(sctbinfo).mtx_grp_attr = lck_grp_attr_alloc_init(); + lck_grp_attr_setdefault(SCTP_BASE_INFO(sctbinfo).mtx_grp_attr); + SCTP_BASE_INFO(sctbinfo).mtx_grp = lck_grp_alloc_init("sctppcb", SCTP_BASE_INFO(sctbinfo).mtx_grp_attr); + SCTP_BASE_INFO(sctbinfo).mtx_attr = lck_attr_alloc_init(); + lck_attr_setdefault(SCTP_BASE_INFO(sctbinfo).mtx_attr); +#else + SCTP_BASE_INFO(sctbinfo).ipi_listhead = &SCTP_BASE_INFO(inplisthead); + SCTP_BASE_INFO(sctbinfo).ipi_lock_grp_attr = lck_grp_attr_alloc_init(); + lck_grp_attr_setdefault(SCTP_BASE_INFO(sctbinfo).ipi_lock_grp_attr); + SCTP_BASE_INFO(sctbinfo).ipi_lock_grp = lck_grp_alloc_init("sctppcb", SCTP_BASE_INFO(sctbinfo).ipi_lock_grp_attr); + SCTP_BASE_INFO(sctbinfo).ipi_lock_attr = lck_attr_alloc_init(); + lck_attr_setdefault(SCTP_BASE_INFO(sctbinfo).ipi_lock_attr); +#endif +#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) + SCTP_BASE_INFO(sctbinfo).ipi_gc = sctp_gc; + in_pcbinfo_attach(&SCTP_BASE_INFO(sctbinfo)); +#endif #endif @@ -6688,17 +6714,6 @@ sctp_pcb_init() /* Master Lock INIT for info structure */ -#if defined(__APPLE__) - /* allocate the lock group attribute for SCTP PCB mutexes */ - SCTP_BASE_INFO(mtx_grp_attr) = lck_grp_attr_alloc_init(); - lck_grp_attr_setdefault(SCTP_BASE_INFO(mtx_grp_attr)); - /* allocate the lock group for SCTP PCB mutexes */ - SCTP_BASE_INFO(mtx_grp) = lck_grp_alloc_init("sctppcb", - SCTP_BASE_INFO(mtx_grp_attr)); - /* allocate the lock attribute for SCTP PCB mutexes */ - SCTP_BASE_INFO(mtx_attr) = lck_attr_alloc_init(); - lck_attr_setdefault(SCTP_BASE_INFO(mtx_attr)); -#endif /* __APPLE__ */ SCTP_INP_INFO_LOCK_INIT(); SCTP_STATLOG_INIT_LOCK(); @@ -6800,6 +6815,9 @@ sctp_pcb_finish(void) SCTP_IPI_ITERATOR_WQ_UNLOCK(); #endif #if defined(__APPLE__) +#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) + in_pcbinfo_detach(&SCTP_BASE_INFO(sctbinfo)); +#endif SCTP_IPI_ITERATOR_WQ_LOCK(); do { msleep(&sctp_it_ctl.iterator_flags, @@ -6948,9 +6966,15 @@ sctp_pcb_finish(void) SCTP_WQ_ADDR_DESTROY(); #if defined(__APPLE__) - lck_grp_attr_free(SCTP_BASE_INFO(mtx_grp_attr)); - lck_grp_free(SCTP_BASE_INFO(mtx_grp)); - lck_attr_free(SCTP_BASE_INFO(mtx_attr)); +#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) + lck_grp_attr_free(SCTP_BASE_INFO(sctbinfo).mtx_grp_attr); + lck_grp_free(SCTP_BASE_INFO(sctbinfo).mtx_grp); + lck_attr_free(SCTP_BASE_INFO(sctbinfo).mtx_attr); +#else + lck_grp_attr_free(SCTP_BASE_INFO(sctbinfo).ipi_lock_grp_attr); + lck_grp_free(SCTP_BASE_INFO(sctbinfo).ipi_lock_grp); + lck_attr_free(SCTP_BASE_INFO(sctbinfo).ipi_lock_attr); +#endif #endif #if defined(__Userspace__) SCTP_TIMERQ_LOCK_DESTROY(); diff --git a/netinet/sctp_pcb.h b/netinet/sctp_pcb.h index e1cad80..bcd2864 100755 --- a/netinet/sctp_pcb.h +++ b/netinet/sctp_pcb.h @@ -189,6 +189,7 @@ struct sctp_epinfo { #if defined(__APPLE__) struct inpcbhead inplisthead; + struct inpcbinfo sctbinfo; #endif /* ep zone info */ sctp_zone_t ipi_zone_ep; @@ -223,20 +224,12 @@ struct sctp_epinfo { userland_mutex_t wq_addr_mtx; #elif defined(__APPLE__) #ifdef _KERN_LOCKS_H_ - lck_grp_attr_t *mtx_grp_attr; - lck_grp_t *mtx_grp; - lck_attr_t *mtx_attr; - lck_rw_t *ipi_ep_mtx; lck_mtx_t *ipi_addr_mtx; lck_mtx_t *ipi_count_mtx; lck_mtx_t *ipi_pktlog_mtx; lck_mtx_t *logging_mtx; lck_mtx_t *wq_addr_mtx; #else - void *mtx_grp_attr; - void *mtx_grp; - void *mtx_attr; - void *ipi_ep_mtx; void *ipi_count_mtx; void *logging_mtx; #endif /* _KERN_LOCKS_H_ */ diff --git a/netinet/sctp_structs.h b/netinet/sctp_structs.h index e25d74c..f333ec8 100755 --- a/netinet/sctp_structs.h +++ b/netinet/sctp_structs.h @@ -236,6 +236,9 @@ struct sctp_net_route { #endif #endif #if defined(__APPLE__) +#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) + struct ifaddr *ro_srcia; +#endif #if !defined(APPLE_LEOPARD) uint32_t ro_flags; #endif diff --git a/netinet/sctp_timer.h b/netinet/sctp_timer.h index 673cc41..3662bd2 100755 --- a/netinet/sctp_timer.h +++ b/netinet/sctp_timer.h @@ -96,8 +96,11 @@ void sctp_audit_retranmission_queue(struct sctp_association *); void sctp_iterator_timer(struct sctp_iterator *it); #if defined(__APPLE__) -void sctp_slowtimo(); - +#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) +void sctp_slowtimo(void); +#else +void sctp_gc(struct inpcbinfo *); +#endif #endif #endif diff --git a/netinet/sctp_uio.h b/netinet/sctp_uio.h index 96551ae..7d84313 100755 --- a/netinet/sctp_uio.h +++ b/netinet/sctp_uio.h @@ -690,9 +690,7 @@ struct sctp_hmacalgo { /* AUTH hmac_id */ #define SCTP_AUTH_HMAC_ID_RSVD 0x0000 #define SCTP_AUTH_HMAC_ID_SHA1 0x0001 /* default, mandatory */ -#if defined(SCTP_SUPPORT_HMAC_SHA256) #define SCTP_AUTH_HMAC_ID_SHA256 0x0003 -#endif /* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */ struct sctp_authkeyid { diff --git a/netinet/sctp_usrreq.c b/netinet/sctp_usrreq.c index 17441bc..d4115ad 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -76,6 +76,8 @@ void sctp_init(uint16_t port, int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), void (*debug_printf)(const char *format, ...)) +#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) +sctp_init(struct protosw *pp SCTP_UNUSED, struct domain *dp SCTP_UNUSED) #else sctp_init(void) #endif @@ -177,8 +179,7 @@ sctp_init(void) #if defined(__APPLE__) SCTP_BASE_VAR(sctp_main_timer_ticks) = 0; sctp_start_main_timer(); - sctp_address_monitor_start(); - sctp_over_udp_start(); + timeout(sctp_delayed_startup, NULL, 1); #endif } @@ -186,6 +187,7 @@ void sctp_finish(void) { #if defined(__APPLE__) + untimeout(sctp_delayed_startup, NULL); sctp_over_udp_stop(); sctp_address_monitor_stop(); sctp_stop_main_timer(); @@ -7799,7 +7801,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) struct pr_usrreqs sctp_usrreqs = { -#if __FreeBSD_version >= 600000 +#if defined(__FreeBSD__) .pru_abort = sctp_abort, .pru_accept = sctp_accept, .pru_attach = sctp_attach, @@ -7823,45 +7825,51 @@ struct pr_usrreqs sctp_usrreqs = { .pru_sockaddr = sctp_ingetaddr, .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive -#else +#elif defined(__APPLE__) + .pru_abort = sctp_abort, + .pru_accept = sctp_accept, + .pru_attach = sctp_attach, + .pru_bind = sctp_bind, + .pru_connect = sctp_connect, + .pru_connect2 = pru_connect2_notsupp, + .pru_control = in_control, + .pru_detach = sctp_detach, + .pru_disconnect = sctp_disconnect, + .pru_listen = sctp_listen, + .pru_peeraddr = sctp_peeraddr, + .pru_rcvd = NULL, + .pru_rcvoob = pru_rcvoob_notsupp, + .pru_send = sctp_sendm, + .pru_sense = pru_sense_null, + .pru_shutdown = sctp_shutdown, + .pru_sockaddr = sctp_ingetaddr, + .pru_sosend = sctp_sosend, + .pru_soreceive = sctp_soreceive, + .pru_sopoll = sopoll +#elif defined(__Windows__) sctp_abort, sctp_accept, sctp_attach, sctp_bind, sctp_connect, pru_connect2_notsupp, -#if defined(__Windows__) NULL, NULL, -#else - in_control, - sctp_detach, -#endif sctp_disconnect, sctp_listen, sctp_peeraddr, NULL, pru_rcvoob_notsupp, -#if defined(__Windows__) NULL, -#else - sctp_sendm, -#endif pru_sense_null, sctp_shutdown, -#if defined(__Windows__) sctp_flush, -#endif sctp_ingetaddr, sctp_sosend, sctp_soreceive, -#if defined(__Windows__) sopoll_generic, NULL, sctp_close -#else - sopoll -#endif #endif }; #elif !defined(__Panda__) && !defined(__Userspace__) diff --git a/netinet/sctp_var.h b/netinet/sctp_var.h index af9edeb..f2a0316 100755 --- a/netinet/sctp_var.h +++ b/netinet/sctp_var.h @@ -436,13 +436,13 @@ void sctp_drain(void); void sctp_init(uint16_t, int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), void (*)(const char *, ...)); -#else -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 +#elif defined(__FreeBSD__) && __FreeBSD_version < 902000 void sctp_init __P((void)); +#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) +void sctp_init(struct protosw *pp, struct domain *dp); #else void sctp_init(void); #endif -#endif void sctp_finish(void); #if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) int sctp_flush(struct socket *, int); diff --git a/netinet6/sctp6_usrreq.c b/netinet6/sctp6_usrreq.c index e003db2..45a3196 100644 --- a/netinet6/sctp6_usrreq.c +++ b/netinet6/sctp6_usrreq.c @@ -1685,7 +1685,7 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) struct pr_usrreqs sctp6_usrreqs = { -#if __FreeBSD_version >= 600000 +#if defined(__FreeBSD__) .pru_abort = sctp6_abort, .pru_accept = sctp_accept, .pru_attach = sctp6_attach, @@ -1709,46 +1709,52 @@ struct pr_usrreqs sctp6_usrreqs = { .pru_sockaddr = sctp6_in6getaddr, .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive -#else +#elif defined(__APPLE__) + .pru_abort = sctp6_abort, + .pru_accept = sctp_accept, + .pru_attach = sctp6_attach, + .pru_bind = sctp6_bind, + .pru_connect = sctp6_connect, + .pru_connect2 = pru_connect2_notsupp, + .pru_control = in6_control, + .pru_detach = sctp6_detach, + .pru_disconnect = sctp6_disconnect, + .pru_listen = sctp_listen, + .pru_peeraddr = sctp6_getpeeraddr, + .pru_rcvd = NULL, + .pru_rcvoob = pru_rcvoob_notsupp, + .pru_send = sctp6_send, + .pru_sense = pru_sense_null, + .pru_shutdown = sctp_shutdown, + .pru_sockaddr = sctp6_in6getaddr, + .pru_sosend = sctp_sosend, + .pru_soreceive = sctp_soreceive, + .pru_sopoll = sopoll +#elif defined(__Windows__) sctp6_abort, sctp_accept, sctp6_attach, sctp6_bind, sctp6_connect, pru_connect2_notsupp, -#if defined(__Windows__) NULL, NULL, -#else - in6_control, - sctp6_detach, -#endif sctp6_disconnect, sctp_listen, sctp6_getpeeraddr, NULL, pru_rcvoob_notsupp, -#if defined(__Windows__) NULL, -#else - sctp6_send, -#endif pru_sense_null, sctp_shutdown, -#if defined(__Windows__) sctp_flush, -#endif sctp6_in6getaddr, sctp_sosend, sctp_soreceive, -#if !defined(__Windows__) - sopoll -#else sopoll_generic, NULL, sctp6_close #endif -#endif }; #elif !defined(__Panda__) && !defined(__Userspace__) |