1 /* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 30 * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.64.2.16 2003/08/24 08:24:38 hsu Exp $ 31 */ 32 33 #include "opt_inet6.h" 34 #include "opt_carp.h" 35 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/kernel.h> 39 #include <sys/jail.h> 40 #include <sys/malloc.h> 41 #include <sys/mbuf.h> 42 #include <sys/proc.h> 43 #include <sys/priv.h> 44 #include <sys/protosw.h> 45 #include <sys/socket.h> 46 #include <sys/socketvar.h> 47 #include <sys/sysctl.h> 48 49 #include <sys/thread2.h> 50 #include <sys/socketvar2.h> 51 #include <sys/msgport2.h> 52 53 #include <machine/stdarg.h> 54 55 #include <net/if.h> 56 #ifdef CARP 57 #include <net/if_types.h> 58 #endif 59 #include <net/route.h> 60 61 #define _IP_VHL 62 #include <netinet/in.h> 63 #include <netinet/in_systm.h> 64 #include <netinet/ip.h> 65 #include <netinet/in_pcb.h> 66 #include <netinet/in_var.h> 67 #include <netinet/ip_var.h> 68 69 #include <net/ip_mroute/ip_mroute.h> 70 #include <net/ipfw/ip_fw.h> 71 #include <net/ipfw3/ip_fw.h> 72 #include <net/dummynet/ip_dummynet.h> 73 #include <net/dummynet3/ip_dummynet3.h> 74 75 struct inpcbinfo ripcbinfo; 76 struct inpcbportinfo ripcbportinfo; 77 78 /* 79 * hooks for multicast routing. They all default to NULL, 80 * so leave them not initialized and rely on BSS being set to 0. 81 */ 82 83 /* The socket used to communicate with the multicast routing daemon. */ 84 struct socket *ip_mrouter; 85 86 /* The various mrouter and rsvp functions */ 87 int (*ip_mrouter_set)(struct socket *, struct sockopt *); 88 int (*ip_mrouter_get)(struct socket *, struct sockopt *); 89 int (*ip_mrouter_done)(void); 90 int (*ip_mforward)(struct ip *, struct ifnet *, struct mbuf *, 91 struct ip_moptions *); 92 int (*mrt_ioctl)(u_long, caddr_t); 93 int (*legal_vif_num)(int); 94 u_long (*ip_mcast_src)(int); 95 96 int (*rsvp_input_p)(struct mbuf **, int *, int); 97 int (*ip_rsvp_vif)(struct socket *, struct sockopt *); 98 void (*ip_rsvp_force_done)(struct socket *); 99 100 /* 101 * Nominal space allocated to a raw ip socket. 102 */ 103 #define RIPSNDQ 8192 104 #define RIPRCVQ 8192 105 106 /* 107 * Raw interface to IP protocol. 108 */ 109 110 /* 111 * Initialize raw connection block queue. 112 */ 113 void 114 rip_init(void) 115 { 116 in_pcbinfo_init(&ripcbinfo, 0, FALSE); 117 in_pcbportinfo_init(&ripcbportinfo, 1, 0); 118 /* 119 * XXX We don't use the hash list for raw IP, but it's easier 120 * to allocate a one entry hash list than it is to check all 121 * over the place for hashbase == NULL. 122 */ 123 ripcbinfo.hashbase = hashinit(1, M_PCB, &ripcbinfo.hashmask); 124 in_pcbportinfo_set(&ripcbinfo, &ripcbportinfo, 1); 125 ripcbinfo.wildcardhashbase = hashinit(1, M_PCB, 126 &ripcbinfo.wildcardhashmask); 127 ripcbinfo.ipi_size = sizeof(struct inpcb); 128 } 129 130 /* 131 * Setup generic address and protocol structures 132 * for raw_input routine, then pass them along with 133 * mbuf chain. 134 */ 135 int 136 rip_input(struct mbuf **mp, int *offp, int proto) 137 { 138 struct sockaddr_in ripsrc = { sizeof ripsrc, AF_INET }; 139 struct mbuf *m = *mp; 140 struct ip *ip = mtod(m, struct ip *); 141 struct inpcb *inp; 142 struct inpcb *last = NULL; 143 struct mbuf *opts = NULL; 144 145 ASSERT_NETISR0; 146 147 *mp = NULL; 148 149 ripsrc.sin_addr = ip->ip_src; 150 LIST_FOREACH(inp, &ripcbinfo.pcblisthead, inp_list) { 151 if (inp->inp_flags & INP_PLACEMARKER) 152 continue; 153 #ifdef INET6 154 if (!INP_ISIPV4(inp)) 155 continue; 156 #endif 157 if (inp->inp_ip_p && inp->inp_ip_p != proto) 158 continue; 159 if (inp->inp_laddr.s_addr != INADDR_ANY && 160 inp->inp_laddr.s_addr != ip->ip_dst.s_addr) 161 continue; 162 if (inp->inp_faddr.s_addr != INADDR_ANY && 163 inp->inp_faddr.s_addr != ip->ip_src.s_addr) 164 continue; 165 if (last) { 166 struct mbuf *n = m_copypacket(m, M_NOWAIT); 167 168 if (n) { 169 lwkt_gettoken(&last->inp_socket->so_rcv.ssb_token); 170 if (last->inp_flags & INP_CONTROLOPTS || 171 last->inp_socket->so_options & SO_TIMESTAMP) 172 ip_savecontrol(last, &opts, ip, n); 173 if (ssb_appendaddr(&last->inp_socket->so_rcv, 174 (struct sockaddr *)&ripsrc, n, 175 opts) == 0) { 176 /* should notify about lost packet */ 177 m_freem(n); 178 if (opts) 179 m_freem(opts); 180 } else { 181 sorwakeup(last->inp_socket); 182 } 183 lwkt_reltoken(&last->inp_socket->so_rcv.ssb_token); 184 opts = NULL; 185 } 186 } 187 last = inp; 188 } 189 /* Check the minimum TTL for socket. */ 190 if (last && ip->ip_ttl < last->inp_ip_minttl) { 191 m_freem(opts); 192 ipstat.ips_delivered--; 193 } else if (last) { 194 if (last->inp_flags & INP_CONTROLOPTS || 195 last->inp_socket->so_options & SO_TIMESTAMP) 196 ip_savecontrol(last, &opts, ip, m); 197 lwkt_gettoken(&last->inp_socket->so_rcv.ssb_token); 198 if (ssb_appendaddr(&last->inp_socket->so_rcv, 199 (struct sockaddr *)&ripsrc, m, opts) == 0) { 200 m_freem(m); 201 if (opts) 202 m_freem(opts); 203 } else { 204 sorwakeup(last->inp_socket); 205 } 206 lwkt_reltoken(&last->inp_socket->so_rcv.ssb_token); 207 } else { 208 m_freem(m); 209 ipstat.ips_noproto++; 210 ipstat.ips_delivered--; 211 } 212 return(IPPROTO_DONE); 213 } 214 215 /* 216 * Generate IP header and pass packet to ip_output. 217 * Tack on options user may have setup with control call. 218 */ 219 int 220 rip_output(struct mbuf *m, struct socket *so, ...) 221 { 222 struct ip *ip; 223 struct inpcb *inp = so->so_pcb; 224 __va_list ap; 225 int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST; 226 u_long dst; 227 228 ASSERT_NETISR0; 229 230 __va_start(ap, so); 231 dst = __va_arg(ap, u_long); 232 __va_end(ap); 233 234 /* 235 * If the user handed us a complete IP packet, use it. 236 * Otherwise, allocate an mbuf for a header and fill it in. 237 */ 238 if ((inp->inp_flags & INP_HDRINCL) == 0) { 239 if (m->m_pkthdr.len + sizeof(struct ip) > IP_MAXPACKET) { 240 m_freem(m); 241 return(EMSGSIZE); 242 } 243 M_PREPEND(m, sizeof(struct ip), M_WAITOK); 244 if (m == NULL) 245 return(ENOBUFS); 246 ip = mtod(m, struct ip *); 247 ip->ip_tos = inp->inp_ip_tos; 248 ip->ip_off = 0; 249 ip->ip_p = inp->inp_ip_p; 250 ip->ip_len = m->m_pkthdr.len; 251 ip->ip_src = inp->inp_laddr; 252 ip->ip_dst.s_addr = dst; 253 ip->ip_ttl = inp->inp_ip_ttl; 254 } else { 255 int hlen; 256 257 if (m->m_pkthdr.len > IP_MAXPACKET) { 258 m_freem(m); 259 return(EMSGSIZE); 260 } 261 if (m->m_len < sizeof(struct ip)) { 262 m = m_pullup(m, sizeof(struct ip)); 263 if (m == NULL) 264 return ENOBUFS; 265 } 266 ip = mtod(m, struct ip *); 267 hlen = IP_VHL_HL(ip->ip_vhl) << 2; 268 269 /* Don't allow header length less than the minimum. */ 270 if (hlen < sizeof(struct ip)) { 271 m_freem(m); 272 return EINVAL; 273 } 274 275 /* 276 * Don't allow both user specified and setsockopt options. 277 * Don't allow packet length sizes that will crash. 278 */ 279 if ((hlen != sizeof(struct ip) && inp->inp_options) || 280 ip->ip_len > m->m_pkthdr.len || ip->ip_len < hlen) { 281 m_freem(m); 282 return EINVAL; 283 } 284 if (ip->ip_id == 0) 285 ip->ip_id = ip_newid(); 286 287 /* Prevent ip_output from overwriting header fields */ 288 flags |= IP_RAWOUTPUT; 289 ipstat.ips_rawout++; 290 } 291 292 return ip_output(m, inp->inp_options, &inp->inp_route, flags, 293 inp->inp_moptions, inp); 294 } 295 296 /* 297 * Raw IP socket option processing. 298 */ 299 void 300 rip_ctloutput(netmsg_t msg) 301 { 302 struct socket *so = msg->base.nm_so; 303 struct sockopt *sopt = msg->ctloutput.nm_sopt; 304 struct inpcb *inp = so->so_pcb; 305 int error, optval; 306 307 ASSERT_NETISR0; 308 309 error = 0; 310 311 /* Get socket's owner cpuid hint */ 312 if (sopt->sopt_level == SOL_SOCKET && 313 sopt->sopt_dir == SOPT_GET && 314 sopt->sopt_name == SO_CPUHINT) { 315 optval = mycpuid; 316 soopt_from_kbuf(sopt, &optval, sizeof(optval)); 317 goto done; 318 } 319 320 if (sopt->sopt_level != IPPROTO_IP) { 321 error = EINVAL; 322 goto done; 323 } 324 325 switch (sopt->sopt_dir) { 326 case SOPT_GET: 327 switch (sopt->sopt_name) { 328 case IP_HDRINCL: 329 optval = inp->inp_flags & INP_HDRINCL; 330 soopt_from_kbuf(sopt, &optval, sizeof optval); 331 break; 332 333 case IP_FW_X: 334 error = ip_fw3_sockopt(sopt); 335 break; 336 337 case IP_FW_ADD: /* ADD actually returns the body... */ 338 case IP_FW_GET: 339 case IP_FW_TBL_GET: 340 case IP_FW_TBL_EXPIRE: /* returns # of expired addresses */ 341 error = ip_fw_sockopt(sopt); 342 break; 343 344 case IP_DUMMYNET_GET: 345 error = ip_dn_sockopt(sopt); 346 break ; 347 348 case MRT_INIT: 349 case MRT_DONE: 350 case MRT_ADD_VIF: 351 case MRT_DEL_VIF: 352 case MRT_ADD_MFC: 353 case MRT_DEL_MFC: 354 case MRT_VERSION: 355 case MRT_ASSERT: 356 case MRT_API_SUPPORT: 357 case MRT_API_CONFIG: 358 case MRT_ADD_BW_UPCALL: 359 case MRT_DEL_BW_UPCALL: 360 error = ip_mrouter_get ? ip_mrouter_get(so, sopt) : 361 EOPNOTSUPP; 362 break; 363 364 default: 365 ip_ctloutput(msg); 366 /* msg invalid now */ 367 return; 368 } 369 break; 370 371 case SOPT_SET: 372 switch (sopt->sopt_name) { 373 case IP_HDRINCL: 374 error = soopt_to_kbuf(sopt, &optval, sizeof optval, 375 sizeof optval); 376 if (error) 377 break; 378 if (optval) 379 inp->inp_flags |= INP_HDRINCL; 380 else 381 inp->inp_flags &= ~INP_HDRINCL; 382 break; 383 384 case IP_FW_X: 385 error = ip_fw3_sockopt(sopt); 386 break; 387 388 case IP_FW_ADD: 389 case IP_FW_DEL: 390 case IP_FW_FLUSH: 391 case IP_FW_ZERO: 392 case IP_FW_RESETLOG: 393 case IP_FW_TBL_CREATE: 394 case IP_FW_TBL_DESTROY: 395 case IP_FW_TBL_ADD: 396 case IP_FW_TBL_DEL: 397 case IP_FW_TBL_FLUSH: 398 case IP_FW_TBL_ZERO: 399 case IP_FW_TBL_EXPIRE: 400 error = ip_fw_sockopt(sopt); 401 break; 402 403 case IP_DUMMYNET_CONFIGURE: 404 case IP_DUMMYNET_DEL: 405 case IP_DUMMYNET_FLUSH: 406 error = ip_dn_sockopt(sopt); 407 break; 408 409 case IP_RSVP_ON: 410 error = ip_rsvp_init(so); 411 break; 412 413 case IP_RSVP_OFF: 414 error = ip_rsvp_done(); 415 break; 416 417 case IP_RSVP_VIF_ON: 418 case IP_RSVP_VIF_OFF: 419 error = ip_rsvp_vif ? 420 ip_rsvp_vif(so, sopt) : EINVAL; 421 break; 422 423 case MRT_INIT: 424 case MRT_DONE: 425 case MRT_ADD_VIF: 426 case MRT_DEL_VIF: 427 case MRT_ADD_MFC: 428 case MRT_DEL_MFC: 429 case MRT_VERSION: 430 case MRT_ASSERT: 431 case MRT_API_SUPPORT: 432 case MRT_API_CONFIG: 433 case MRT_ADD_BW_UPCALL: 434 case MRT_DEL_BW_UPCALL: 435 error = ip_mrouter_set ? ip_mrouter_set(so, sopt) : 436 EOPNOTSUPP; 437 break; 438 439 default: 440 ip_ctloutput(msg); 441 /* msg invalid now */ 442 return; 443 } 444 break; 445 } 446 done: 447 lwkt_replymsg(&msg->lmsg, error); 448 } 449 450 /* 451 * This function exists solely to receive the PRC_IFDOWN messages which 452 * are sent by if_down(). It looks for an ifaddr whose ifa_addr is sa, 453 * and calls in_ifadown() to remove all routes corresponding to that address. 454 * It also receives the PRC_IFUP messages from if_up() and reinstalls the 455 * interface routes. 456 */ 457 void 458 rip_ctlinput(netmsg_t msg) 459 { 460 int cmd = msg->ctlinput.nm_cmd; 461 struct sockaddr *sa = msg->ctlinput.nm_arg; 462 struct in_ifaddr *ia; 463 struct in_ifaddr_container *iac; 464 struct ifnet *ifp; 465 int err; 466 int flags; 467 468 ASSERT_NETISR0; 469 470 switch (cmd) { 471 case PRC_IFDOWN: 472 TAILQ_FOREACH(iac, &in_ifaddrheads[mycpuid], ia_link) { 473 ia = iac->ia; 474 475 if (ia->ia_ifa.ifa_addr == sa && 476 (ia->ia_flags & IFA_ROUTE)) { 477 /* 478 * in_ifscrub kills the interface route. 479 */ 480 in_ifscrub(ia->ia_ifp, ia); 481 /* 482 * in_ifadown gets rid of all the rest of 483 * the routes. This is not quite the right 484 * thing to do, but at least if we are running 485 * a routing process they will come back. 486 */ 487 in_ifadown(&ia->ia_ifa, 0); 488 break; 489 } 490 } 491 break; 492 493 case PRC_IFUP: 494 ia = NULL; 495 TAILQ_FOREACH(iac, &in_ifaddrheads[mycpuid], ia_link) { 496 if (iac->ia->ia_ifa.ifa_addr == sa) { 497 ia = iac->ia; 498 break; 499 } 500 } 501 if (ia == NULL || (ia->ia_flags & IFA_ROUTE)) 502 goto done; 503 flags = RTF_UP; 504 ifp = ia->ia_ifa.ifa_ifp; 505 506 #ifdef CARP 507 /* 508 * Don't add prefix routes for CARP interfaces. 509 * Prefix routes creation is handled by CARP 510 * interfaces themselves. 511 */ 512 if (ifp->if_type == IFT_CARP) 513 goto done; 514 #endif 515 516 if ((ifp->if_flags & IFF_LOOPBACK) || 517 (ifp->if_flags & IFF_POINTOPOINT)) 518 flags |= RTF_HOST; 519 520 err = rtinit(&ia->ia_ifa, RTM_ADD, flags); 521 if (err == 0) 522 ia->ia_flags |= IFA_ROUTE; 523 break; 524 } 525 done: 526 lwkt_replymsg(&msg->lmsg, 0); 527 } 528 529 u_long rip_sendspace = RIPSNDQ; 530 u_long rip_recvspace = RIPRCVQ; 531 532 SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW, 533 &rip_sendspace, 0, "Maximum outgoing raw IP datagram size"); 534 SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, 535 &rip_recvspace, 0, "Maximum incoming raw IP datagram size"); 536 537 static void 538 rip_attach(netmsg_t msg) 539 { 540 struct socket *so = msg->base.nm_so; 541 int proto = msg->attach.nm_proto; 542 struct pru_attach_info *ai = msg->attach.nm_ai; 543 struct inpcb *inp; 544 int error; 545 546 ASSERT_NETISR0; 547 548 inp = so->so_pcb; 549 if (inp) 550 panic("rip_attach"); 551 error = priv_check_cred(ai->p_ucred, PRIV_NETINET_RAW, NULL_CRED_OKAY); 552 if (error) 553 goto done; 554 555 error = soreserve(so, rip_sendspace, rip_recvspace, ai->sb_rlimit); 556 if (error) 557 goto done; 558 559 error = in_pcballoc(so, &ripcbinfo); 560 if (error == 0) { 561 inp = (struct inpcb *)so->so_pcb; 562 inp->inp_ip_p = proto; 563 inp->inp_ip_ttl = ip_defttl; 564 } 565 done: 566 lwkt_replymsg(&msg->lmsg, error); 567 } 568 569 static void 570 rip_detach(netmsg_t msg) 571 { 572 struct socket *so = msg->base.nm_so; 573 struct inpcb *inp; 574 575 ASSERT_NETISR0; 576 577 inp = so->so_pcb; 578 if (inp == NULL) 579 panic("rip_detach"); 580 if (so == ip_mrouter && ip_mrouter_done) 581 ip_mrouter_done(); 582 if (ip_rsvp_force_done) 583 ip_rsvp_force_done(so); 584 if (so == ip_rsvpd) 585 ip_rsvp_done(); 586 in_pcbdetach(inp); 587 lwkt_replymsg(&msg->lmsg, 0); 588 } 589 590 static void 591 rip_abort(netmsg_t msg) 592 { 593 /* 594 * Raw socket does not support listen(2), 595 * so this should never be called. 596 */ 597 panic("rip_abort is called"); 598 } 599 600 static void 601 rip_disconnect(netmsg_t msg) 602 { 603 struct socket *so = msg->base.nm_so; 604 int error; 605 606 ASSERT_NETISR0; 607 608 if (so->so_state & SS_ISCONNECTED) { 609 soisdisconnected(so); 610 error = 0; 611 } else { 612 error = ENOTCONN; 613 } 614 lwkt_replymsg(&msg->lmsg, error); 615 } 616 617 static void 618 rip_bind(netmsg_t msg) 619 { 620 struct socket *so = msg->base.nm_so; 621 struct sockaddr *nam = msg->bind.nm_nam; 622 struct inpcb *inp = so->so_pcb; 623 struct sockaddr_in *addr = (struct sockaddr_in *)nam; 624 int error; 625 626 ASSERT_NETISR0; 627 628 if (nam->sa_len == sizeof(*addr)) { 629 if (ifnet_array_isempty() || 630 ((addr->sin_family != AF_INET) && 631 (addr->sin_family != AF_IMPLINK)) || 632 (addr->sin_addr.s_addr != INADDR_ANY && 633 ifa_ifwithaddr((struct sockaddr *)addr) == 0)) { 634 error = EADDRNOTAVAIL; 635 } else { 636 inp->inp_laddr = addr->sin_addr; 637 error = 0; 638 } 639 } else { 640 error = EINVAL; 641 } 642 lwkt_replymsg(&msg->lmsg, error); 643 } 644 645 static void 646 rip_connect(netmsg_t msg) 647 { 648 struct socket *so = msg->base.nm_so; 649 struct sockaddr *nam = msg->connect.nm_nam; 650 struct inpcb *inp = so->so_pcb; 651 struct sockaddr_in *addr = (struct sockaddr_in *)nam; 652 int error; 653 654 ASSERT_NETISR0; 655 656 if (nam->sa_len != sizeof(*addr)) { 657 error = EINVAL; 658 } else if (ifnet_array_isempty()) { 659 error = EADDRNOTAVAIL; 660 } else { 661 if ((addr->sin_family != AF_INET) && 662 (addr->sin_family != AF_IMPLINK)) { 663 error = EAFNOSUPPORT; 664 } else { 665 inp->inp_faddr = addr->sin_addr; 666 soisconnected(so); 667 error = 0; 668 } 669 } 670 lwkt_replymsg(&msg->lmsg, error); 671 } 672 673 static void 674 rip_shutdown(netmsg_t msg) 675 { 676 ASSERT_NETISR0; 677 678 socantsendmore(msg->base.nm_so); 679 lwkt_replymsg(&msg->lmsg, 0); 680 } 681 682 static void 683 rip_send(netmsg_t msg) 684 { 685 struct socket *so = msg->base.nm_so; 686 struct mbuf *m = msg->send.nm_m; 687 /*struct mbuf *control = msg->send.nm_control;*/ 688 struct sockaddr *nam = msg->send.nm_addr; 689 /*int flags = msg->send.nm_flags;*/ 690 struct inpcb *inp = so->so_pcb; 691 u_long dst; 692 int error; 693 694 ASSERT_NETISR0; 695 696 if (so->so_state & SS_ISCONNECTED) { 697 if (nam) { 698 m_freem(m); 699 error = EISCONN; 700 } else { 701 dst = inp->inp_faddr.s_addr; 702 error = rip_output(m, so, dst); 703 } 704 } else { 705 if (nam == NULL) { 706 m_freem(m); 707 error = ENOTCONN; 708 } else { 709 dst = ((struct sockaddr_in *)nam)->sin_addr.s_addr; 710 error = rip_output(m, so, dst); 711 } 712 } 713 lwkt_replymsg(&msg->lmsg, error); 714 } 715 716 SYSCTL_PROC(_net_inet_raw, OID_AUTO/*XXX*/, pcblist, CTLFLAG_RD, &ripcbinfo, 1, 717 in_pcblist_range, "S,xinpcb", "List of active raw IP sockets"); 718 719 struct pr_usrreqs rip_usrreqs = { 720 .pru_abort = rip_abort, 721 .pru_accept = pr_generic_notsupp, 722 .pru_attach = rip_attach, 723 .pru_bind = rip_bind, 724 .pru_connect = rip_connect, 725 .pru_connect2 = pr_generic_notsupp, 726 .pru_control = in_control_dispatch, 727 .pru_detach = rip_detach, 728 .pru_disconnect = rip_disconnect, 729 .pru_listen = pr_generic_notsupp, 730 .pru_peeraddr = in_setpeeraddr_dispatch, 731 .pru_rcvd = pr_generic_notsupp, 732 .pru_rcvoob = pr_generic_notsupp, 733 .pru_send = rip_send, 734 .pru_sense = pru_sense_null, 735 .pru_shutdown = rip_shutdown, 736 .pru_sockaddr = in_setsockaddr_dispatch, 737 .pru_sosend = sosend, 738 .pru_soreceive = soreceive 739 }; 740