Lines Matching +full:break +full:- +full:control
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
93 m->m_pkthdr.len, in sctp6_input_with_port()
94 if_name(m->m_pkthdr.rcvif), in sctp6_input_with_port()
95 (int)m->m_pkthdr.csum_flags, CSUM_BITS); in sctp6_input_with_port()
96 mflowid = m->m_pkthdr.flowid; in sctp6_input_with_port()
103 if (m->m_len < offset) { in sctp6_input_with_port()
113 offset -= sizeof(struct sctp_chunkhdr); in sctp6_input_with_port()
117 src.sin6_port = sh->src_port; in sctp6_input_with_port()
118 src.sin6_addr = ip6->ip6_src; in sctp6_input_with_port()
119 if (in6_setscope(&src.sin6_addr, m->m_pkthdr.rcvif, NULL) != 0) { in sctp6_input_with_port()
125 dst.sin6_port = sh->dest_port; in sctp6_input_with_port()
126 dst.sin6_addr = ip6->ip6_dst; in sctp6_input_with_port()
127 if (in6_setscope(&dst.sin6_addr, m->m_pkthdr.rcvif, NULL) != 0) { in sctp6_input_with_port()
130 length = ntohs(ip6->ip6_plen) + iphlen; in sctp6_input_with_port()
138 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { in sctp6_input_with_port()
142 if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { in sctp6_input_with_port()
187 if (net->dest_state & SCTP_ADDR_REACHABLE) { in sctp6_notify()
189 net->dest_state &= ~SCTP_ADDR_REACHABLE; in sctp6_notify()
190 net->dest_state &= ~SCTP_ADDR_PF; in sctp6_notify()
196 break; in sctp6_notify()
206 break; in sctp6_notify()
208 if (net->dest_state & SCTP_ADDR_NO_PMTUD) { in sctp6_notify()
210 break; in sctp6_notify()
212 if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { in sctp6_notify()
220 if (net->port) { in sctp6_notify()
221 next_mtu -= sizeof(struct udphdr); in sctp6_notify()
223 if (net->mtu > next_mtu) { in sctp6_notify()
224 net->mtu = next_mtu; in sctp6_notify()
225 if (net->port) { in sctp6_notify()
226 sctp_hc_set_mtu(&net->ro._l_addr, inp->fibnum, next_mtu + sizeof(struct udphdr)); in sctp6_notify()
228 sctp_hc_set_mtu(&net->ro._l_addr, inp->fibnum, next_mtu); in sctp6_notify()
232 if (stcb->asoc.smallest_mtu > next_mtu) { in sctp6_notify()
240 break; in sctp6_notify()
243 break; in sctp6_notify()
256 if (icmp6_errmap(ip6cp->ip6c_icmp6) == 0) { in sctp6_ctlinput()
264 if (ip6cp->ip6c_m->m_pkthdr.len < in sctp6_ctlinput()
265 (int32_t)(ip6cp->ip6c_off + offsetof(struct sctphdr, checksum))) { in sctp6_ctlinput()
271 m_copydata(ip6cp->ip6c_m, in sctp6_ctlinput()
272 ip6cp->ip6c_off, in sctp6_ctlinput()
279 src.sin6_addr = ip6cp->ip6c_ip6->ip6_src; in sctp6_ctlinput()
280 if (in6_setscope(&src.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { in sctp6_ctlinput()
287 dst.sin6_addr = ip6cp->ip6c_ip6->ip6_dst; in sctp6_ctlinput()
288 if (in6_setscope(&dst.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { in sctp6_ctlinput()
306 if (ntohl(sh.v_tag) != stcb->asoc.peer_vtag) { in sctp6_ctlinput()
311 if (ip6cp->ip6c_m->m_pkthdr.len >= in sctp6_ctlinput()
312 ip6cp->ip6c_off + sizeof(struct sctphdr) + in sctp6_ctlinput()
323 m_copydata(ip6cp->ip6c_m, in sctp6_ctlinput()
324 ip6cp->ip6c_off + in sctp6_ctlinput()
328 m_copydata(ip6cp->ip6c_m, in sctp6_ctlinput()
329 ip6cp->ip6c_off + in sctp6_ctlinput()
335 (ntohl(initiate_tag) != stcb->asoc.my_vtag)) { in sctp6_ctlinput()
345 ip6cp->ip6c_icmp6->icmp6_type, in sctp6_ctlinput()
346 ip6cp->ip6c_icmp6->icmp6_code, in sctp6_ctlinput()
347 ntohl(ip6cp->ip6c_icmp6->icmp6_mtu)); in sctp6_ctlinput()
350 /* reduce inp's ref-count */ in sctp6_ctlinput()
378 if (req->newptr == NULL) in sctp6_getcred()
380 error = priv_check(req->td, PRIV_NETINET_GETCRED); in sctp6_getcred()
384 if (req->newlen != sizeof(addrs)) { in sctp6_getcred()
388 if (req->oldlen != sizeof(struct ucred)) { in sctp6_getcred()
399 if (stcb == NULL || inp == NULL || inp->sctp_socket == NULL) { in sctp6_getcred()
401 /* reduce ref-count */ in sctp6_getcred()
419 error = cr_canseesocket(req->td->td_ucred, inp->sctp_socket); in sctp6_getcred()
424 cru2x(inp->sctp_socket->so_cred, &xuc); in sctp6_getcred()
443 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_attach()
449 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { in sctp6_attach()
457 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_attach()
459 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */ in sctp6_attach()
461 inp->ip_inp.inp.inp_vflag |= INP_IPV6; in sctp6_attach()
462 inp->ip_inp.inp.in6p_hops = -1; /* use kernel default */ in sctp6_attach()
463 inp->ip_inp.inp.in6p_cksum = -1; /* just to be sure */ in sctp6_attach()
468 * wildcard address, which may match an IPv4-mapped IPv6 address. in sctp6_attach()
470 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl); in sctp6_attach()
483 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_bind()
490 switch (addr->sa_family) { in sctp6_bind()
493 if (addr->sa_len != sizeof(struct sockaddr_in)) { in sctp6_bind()
497 break; in sctp6_bind()
501 if (addr->sa_len != sizeof(struct sockaddr_in6)) { in sctp6_bind()
505 break; in sctp6_bind()
512 vflagsav = inp->ip_inp.inp.inp_vflag; in sctp6_bind()
513 inp->ip_inp.inp.inp_vflag &= ~INP_IPV4; in sctp6_bind()
514 inp->ip_inp.inp.inp_vflag |= INP_IPV6; in sctp6_bind()
516 switch (addr->sa_family) { in sctp6_bind()
520 inp->ip_inp.inp.inp_vflag |= INP_IPV4; in sctp6_bind()
521 inp->ip_inp.inp.inp_vflag &= ~INP_IPV6; in sctp6_bind()
522 break; in sctp6_bind()
531 if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) { in sctp6_bind()
532 inp->ip_inp.inp.inp_vflag |= INP_IPV4; in sctp6_bind()
535 if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) { in sctp6_bind()
539 inp->ip_inp.inp.inp_vflag |= INP_IPV4; in sctp6_bind()
540 inp->ip_inp.inp.inp_vflag &= ~INP_IPV6; in sctp6_bind()
545 break; in sctp6_bind()
549 break; in sctp6_bind()
556 if (addr->sa_family == AF_INET) { in sctp6_bind()
565 if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) { in sctp6_bind()
566 /* can't bind v4-mapped addrs either! */ in sctp6_bind()
576 inp->ip_inp.inp.inp_vflag = vflagsav; in sctp6_bind()
590 struct mbuf *control, struct thread *p);
594 struct mbuf *control, struct thread *p) in sctp6_send() argument
603 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_send()
605 if (control) { in sctp6_send()
606 SCTP_RELEASE_PKT(control); in sctp6_send()
607 control = NULL; in sctp6_send()
617 if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) && in sctp6_send()
623 if (control) { in sctp6_send()
624 SCTP_RELEASE_PKT(control); in sctp6_send()
625 control = NULL; in sctp6_send()
630 switch (addr->sa_family) { in sctp6_send()
633 if (addr->sa_len != sizeof(struct sockaddr_in)) { in sctp6_send()
634 if (control) { in sctp6_send()
635 SCTP_RELEASE_PKT(control); in sctp6_send()
636 control = NULL; in sctp6_send()
642 break; in sctp6_send()
646 if (addr->sa_len != sizeof(struct sockaddr_in6)) { in sctp6_send()
647 if (control) { in sctp6_send()
648 SCTP_RELEASE_PKT(control); in sctp6_send()
649 control = NULL; in sctp6_send()
655 break; in sctp6_send()
658 if (control) { in sctp6_send()
659 SCTP_RELEASE_PKT(control); in sctp6_send()
660 control = NULL; in sctp6_send()
671 * v4 addr or v4-mapped addr in sctp6_send()
673 if (addr->sa_family == AF_INET) { in sctp6_send()
674 if (control) { in sctp6_send()
675 SCTP_RELEASE_PKT(control); in sctp6_send()
676 control = NULL; in sctp6_send()
682 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp6_send()
683 if (control) { in sctp6_send()
684 SCTP_RELEASE_PKT(control); in sctp6_send()
685 control = NULL; in sctp6_send()
692 if ((addr->sa_family == AF_INET6) && in sctp6_send()
693 IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp6_send()
696 /* convert v4-mapped into v4 addr and send */ in sctp6_send()
698 return (sctp_sendm(so, flags, m, (struct sockaddr *)&sin, control, p)); in sctp6_send()
702 /* now what about control */ in sctp6_send()
703 if (control) { in sctp6_send()
704 if (inp->control) { in sctp6_send()
705 SCTP_PRINTF("huh? control set?\n"); in sctp6_send()
706 SCTP_RELEASE_PKT(inp->control); in sctp6_send()
707 inp->control = NULL; in sctp6_send()
709 inp->control = control; in sctp6_send()
712 if (inp->pkt) { in sctp6_send()
713 SCTP_BUF_NEXT(inp->pkt_last) = m; in sctp6_send()
714 inp->pkt_last = m; in sctp6_send()
716 inp->pkt_last = inp->pkt = m; in sctp6_send()
725 * re-defining sosend() to use sctp_sosend(). One can in sctp6_send()
733 ret = sctp_output(inp, inp->pkt, addr, inp->control, p, flags); in sctp6_send()
735 inp->pkt = NULL; in sctp6_send()
736 inp->control = NULL; in sctp6_send()
756 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_connect()
766 switch (addr->sa_family) { in sctp6_connect()
769 if (addr->sa_len != sizeof(struct sockaddr_in)) { in sctp6_connect()
773 break; in sctp6_connect()
777 if (addr->sa_len != sizeof(struct sockaddr_in6)) { in sctp6_connect()
781 break; in sctp6_connect()
788 vrf_id = inp->def_vrf_id; in sctp6_connect()
791 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == in sctp6_connect()
803 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && in sctp6_connect()
804 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { in sctp6_connect()
816 * addr or v4-mapped addr in sctp6_connect()
818 if (addr->sa_family == AF_INET) { in sctp6_connect()
824 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp6_connect()
831 if ((addr->sa_family == AF_INET6) && in sctp6_connect()
832 IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp6_connect()
833 /* convert v4-mapped into v4 addr */ in sctp6_connect()
839 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { in sctp6_connect()
840 stcb = LIST_FIRST(&inp->sctp_asoc_list); in sctp6_connect()
867 inp->sctp_ep.pre_open_stream_count, in sctp6_connect()
868 inp->sctp_ep.port, p, in sctp6_connect()
876 (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); in sctp6_connect()
898 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_getaddr()
904 sin6->sin6_port = inp->sctp_lport; in sctp6_getaddr()
905 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp6_getaddr()
907 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { in sctp6_getaddr()
913 stcb = LIST_FIRST(&inp->sctp_asoc_list); in sctp6_getaddr()
921 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { in sctp6_getaddr()
922 sin_a6 = (struct sockaddr_in6 *)&net->ro._l_addr; in sctp6_getaddr()
927 if (sin_a6->sin6_family == AF_INET6) { in sctp6_getaddr()
929 break; in sctp6_getaddr()
938 vrf_id = inp->def_vrf_id; in sctp6_getaddr()
939 sctp_ifa = sctp_source_address_selection(inp, stcb, (sctp_route_t *)&net->ro, net, 0, vrf_id); in sctp6_getaddr()
941 sin6->sin6_addr = sctp_ifa->address.sin6.sin6_addr; in sctp6_getaddr()
945 memset(&sin6->sin6_addr, 0, sizeof(sin6->sin6_addr)); in sctp6_getaddr()
952 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { in sctp6_getaddr()
953 if (laddr->ifa->address.sa.sa_family == AF_INET6) { in sctp6_getaddr()
956 sin_a = &laddr->ifa->address.sin6; in sctp6_getaddr()
957 sin6->sin6_addr = sin_a->sin6_addr; in sctp6_getaddr()
959 break; in sctp6_getaddr()
993 inp = (struct sctp_inpcb *)so->so_pcb; in sctp6_peeraddr()
995 ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0)) { in sctp6_peeraddr()
1001 stcb = LIST_FIRST(&inp->sctp_asoc_list); in sctp6_peeraddr()
1011 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { in sctp6_peeraddr()
1012 sin_a6 = (struct sockaddr_in6 *)&net->ro._l_addr; in sctp6_peeraddr()
1013 if (sin_a6->sin6_family == AF_INET6) { in sctp6_peeraddr()
1015 sin6->sin6_port = stcb->rport; in sctp6_peeraddr()
1016 sin6->sin6_addr = sin_a6->sin6_addr; in sctp6_peeraddr()
1017 break; in sctp6_peeraddr()