ipx_usrreq.c (24659) | ipx_usrreq.c (25345) |
---|---|
1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)ipx_usrreq.c 35 * | 1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)ipx_usrreq.c 35 * |
36 * $Id: ipx_usrreq.c,v 1.11 1997/02/22 09:41:57 peter Exp $ | 36 * $Id: ipx_usrreq.c,v 1.12 1997/04/05 20:05:09 jhay Exp $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/queue.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/malloc.h> 44#include <sys/mbuf.h> | 37 */ 38 39#include <sys/param.h> 40#include <sys/queue.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/malloc.h> 44#include <sys/mbuf.h> |
45#include <sys/proc.h> |
|
45#include <sys/protosw.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> 48#include <sys/errno.h> 49#include <sys/stat.h> 50#include <sys/sysctl.h> 51 52#include <net/if.h> --- 17 unchanged lines hidden (view full) --- 70int ipxsendspace = IPXSNDQ; 71SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxsendspace, CTLFLAG_RW, 72 &ipxsendspace, 0, ""); 73int ipxrecvspace = IPXRCVQ; 74SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, 75 &ipxrecvspace, 0, ""); 76 77static int ipx_usr_abort(struct socket *so); | 46#include <sys/protosw.h> 47#include <sys/socket.h> 48#include <sys/socketvar.h> 49#include <sys/errno.h> 50#include <sys/stat.h> 51#include <sys/sysctl.h> 52 53#include <net/if.h> --- 17 unchanged lines hidden (view full) --- 71int ipxsendspace = IPXSNDQ; 72SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxsendspace, CTLFLAG_RW, 73 &ipxsendspace, 0, ""); 74int ipxrecvspace = IPXRCVQ; 75SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, 76 &ipxrecvspace, 0, ""); 77 78static int ipx_usr_abort(struct socket *so); |
78static int ipx_attach(struct socket *so, int proto); 79static int ipx_bind(struct socket *so, struct mbuf *nam); 80static int ipx_connect(struct socket *so, struct mbuf *nam); | 79static int ipx_attach(struct socket *so, int proto, struct proc *p); 80static int ipx_bind(struct socket *so, struct mbuf *nam, struct proc *p); 81static int ipx_connect(struct socket *so, struct mbuf *nam, struct proc *p); |
81static int ipx_detach(struct socket *so); 82static int ipx_disconnect(struct socket *so); 83static int ipx_send(struct socket *so, int flags, struct mbuf *m, | 82static int ipx_detach(struct socket *so); 83static int ipx_disconnect(struct socket *so); 84static int ipx_send(struct socket *so, int flags, struct mbuf *m, |
84 struct mbuf *addr, struct mbuf *control); | 85 struct mbuf *addr, struct mbuf *control, struct proc *p); |
85static int ipx_shutdown(struct socket *so); | 86static int ipx_shutdown(struct socket *so); |
86static int ripx_attach(struct socket *so, int proto); | 87static int ripx_attach(struct socket *so, int proto, struct proc *p); |
87 88struct pr_usrreqs ipx_usrreqs = { 89 ipx_usr_abort, pru_accept_notsupp, ipx_attach, ipx_bind, 90 ipx_connect, pru_connect2_notsupp, ipx_control, ipx_detach, 91 ipx_disconnect, pru_listen_notsupp, ipx_peeraddr, pru_rcvd_notsupp, 92 pru_rcvoob_notsupp, ipx_send, pru_sense_null, ipx_shutdown, 93 ipx_sockaddr 94}; --- 212 unchanged lines hidden (view full) --- 307#endif /* ancient_history */ 308 if (noipxRoute) 309 ro = 0; 310 return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST)); 311} 312 313/* ARGSUSED */ 314int | 88 89struct pr_usrreqs ipx_usrreqs = { 90 ipx_usr_abort, pru_accept_notsupp, ipx_attach, ipx_bind, 91 ipx_connect, pru_connect2_notsupp, ipx_control, ipx_detach, 92 ipx_disconnect, pru_listen_notsupp, ipx_peeraddr, pru_rcvd_notsupp, 93 pru_rcvoob_notsupp, ipx_send, pru_sense_null, ipx_shutdown, 94 ipx_sockaddr 95}; --- 212 unchanged lines hidden (view full) --- 308#endif /* ancient_history */ 309 if (noipxRoute) 310 ro = 0; 311 return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST)); 312} 313 314/* ARGSUSED */ 315int |
315ipx_ctloutput(req, so, level, name, value) | 316ipx_ctloutput(req, so, level, name, value, p) |
316 int req, level; 317 struct socket *so; 318 int name; 319 struct mbuf **value; | 317 int req, level; 318 struct socket *so; 319 int name; 320 struct mbuf **value; |
321 struct proc *p; |
|
320{ 321 register struct mbuf *m; 322 struct ipxpcb *ipxp = sotoipxpcb(so); 323 int mask, error = 0; 324 /*extern long ipx_pexseq;*/ /*XXX*//*JRE*/ 325 326 if (ipxp == NULL) 327 return (EINVAL); --- 75 unchanged lines hidden (view full) --- 403 { 404 register struct ipx *ipx 405 = mtod(*value, struct ipx *); 406 ipxp->ipxp_dpt = ipx->ipx_pt; 407 } 408 break; 409#ifdef IPXIP 410 case SO_IPXIP_ROUTE: | 322{ 323 register struct mbuf *m; 324 struct ipxpcb *ipxp = sotoipxpcb(so); 325 int mask, error = 0; 326 /*extern long ipx_pexseq;*/ /*XXX*//*JRE*/ 327 328 if (ipxp == NULL) 329 return (EINVAL); --- 75 unchanged lines hidden (view full) --- 405 { 406 register struct ipx *ipx 407 = mtod(*value, struct ipx *); 408 ipxp->ipxp_dpt = ipx->ipx_pt; 409 } 410 break; 411#ifdef IPXIP 412 case SO_IPXIP_ROUTE: |
411 error = ipxip_route(so, *value); | 413 error = ipxip_route(so, *value, p); |
412 break; 413#endif /* IPXIP */ 414#ifdef IPXTUNNEL 415 case SO_IPXTUNNEL_ROUTE | 414 break; 415#endif /* IPXIP */ 416#ifdef IPXTUNNEL 417 case SO_IPXTUNNEL_ROUTE |
416 error = ipxtun_route(so, *value); | 418 error = ipxtun_route(so, *value, p); |
417 break; 418#endif 419 default: 420 error = EINVAL; 421 } 422 if (value && *value) 423 m_freem(*value); 424 break; --- 12 unchanged lines hidden (view full) --- 437 ipx_pcbdetach(ipxp); 438 splx(s); 439 sofree(so); 440 soisdisconnected(so); 441 return (0); 442} 443 444static int | 419 break; 420#endif 421 default: 422 error = EINVAL; 423 } 424 if (value && *value) 425 m_freem(*value); 426 break; --- 12 unchanged lines hidden (view full) --- 439 ipx_pcbdetach(ipxp); 440 splx(s); 441 sofree(so); 442 soisdisconnected(so); 443 return (0); 444} 445 446static int |
445ipx_attach(so, proto) | 447ipx_attach(so, proto, p) |
446 struct socket *so; 447 int proto; | 448 struct socket *so; 449 int proto; |
450 struct proc *p; |
|
448{ 449 int error; 450 int s; 451 struct ipxpcb *ipxp = sotoipxpcb(so); 452 453 if (ipxp != NULL) 454 return (EINVAL); 455 s = splnet(); | 451{ 452 int error; 453 int s; 454 struct ipxpcb *ipxp = sotoipxpcb(so); 455 456 if (ipxp != NULL) 457 return (EINVAL); 458 s = splnet(); |
456 error = ipx_pcballoc(so, &ipxpcb); | 459 error = ipx_pcballoc(so, &ipxpcb, p); |
457 splx(s); 458 if (error == 0) 459 error = soreserve(so, ipxsendspace, ipxrecvspace); 460 return (error); 461} 462 463static int | 460 splx(s); 461 if (error == 0) 462 error = soreserve(so, ipxsendspace, ipxrecvspace); 463 return (error); 464} 465 466static int |
464ipx_bind(so, nam) | 467ipx_bind(so, nam, p) |
465 struct socket *so; 466 struct mbuf *nam; | 468 struct socket *so; 469 struct mbuf *nam; |
470 struct proc *p; |
|
467{ 468 struct ipxpcb *ipxp = sotoipxpcb(so); 469 | 471{ 472 struct ipxpcb *ipxp = sotoipxpcb(so); 473 |
470 return (ipx_pcbbind(ipxp, nam)); | 474 return (ipx_pcbbind(ipxp, nam, p)); |
471} 472 473static int | 475} 476 477static int |
474ipx_connect(so, nam) | 478ipx_connect(so, nam, p) |
475 struct socket *so; 476 struct mbuf *nam; | 479 struct socket *so; 480 struct mbuf *nam; |
481 struct proc *p; |
|
477{ 478 int error; 479 int s; 480 struct ipxpcb *ipxp = sotoipxpcb(so); 481 482 if (!ipx_nullhost(ipxp->ipxp_faddr)) 483 return (EISCONN); 484 s = splnet(); | 482{ 483 int error; 484 int s; 485 struct ipxpcb *ipxp = sotoipxpcb(so); 486 487 if (!ipx_nullhost(ipxp->ipxp_faddr)) 488 return (EISCONN); 489 s = splnet(); |
485 error = ipx_pcbconnect(ipxp, nam); | 490 error = ipx_pcbconnect(ipxp, nam, p); |
486 splx(s); 487 if (error == 0) 488 soisconnected(so); 489 return (error); 490} 491 492static int 493ipx_detach(so) --- 33 unchanged lines hidden (view full) --- 527{ 528 struct ipxpcb *ipxp = sotoipxpcb(so); 529 530 ipx_setpeeraddr(ipxp, nam); 531 return (0); 532} 533 534static int | 491 splx(s); 492 if (error == 0) 493 soisconnected(so); 494 return (error); 495} 496 497static int 498ipx_detach(so) --- 33 unchanged lines hidden (view full) --- 532{ 533 struct ipxpcb *ipxp = sotoipxpcb(so); 534 535 ipx_setpeeraddr(ipxp, nam); 536 return (0); 537} 538 539static int |
535ipx_send(so, flags, m, nam, control) | 540ipx_send(so, flags, m, nam, control, p) |
536 struct socket *so; 537 int flags; 538 struct mbuf *m; 539 struct mbuf *nam; 540 struct mbuf *control; | 541 struct socket *so; 542 int flags; 543 struct mbuf *m; 544 struct mbuf *nam; 545 struct mbuf *control; |
546 struct proc *p; |
|
541{ 542 int error; 543 struct ipxpcb *ipxp = sotoipxpcb(so); 544 struct ipx_addr laddr; 545 int s = 0; 546 547 if (nam) { 548 laddr = ipxp->ipxp_laddr; 549 if (!ipx_nullhost(ipxp->ipxp_faddr)) { 550 error = EISCONN; 551 goto send_release; 552 } 553 /* 554 * Must block input while temporarily connected. 555 */ 556 s = splnet(); | 547{ 548 int error; 549 struct ipxpcb *ipxp = sotoipxpcb(so); 550 struct ipx_addr laddr; 551 int s = 0; 552 553 if (nam) { 554 laddr = ipxp->ipxp_laddr; 555 if (!ipx_nullhost(ipxp->ipxp_faddr)) { 556 error = EISCONN; 557 goto send_release; 558 } 559 /* 560 * Must block input while temporarily connected. 561 */ 562 s = splnet(); |
557 error = ipx_pcbconnect(ipxp, nam); | 563 error = ipx_pcbconnect(ipxp, nam, p); |
558 if (error) { 559 splx(s); 560 goto send_release; 561 } 562 } else { 563 if (ipx_nullhost(ipxp->ipxp_faddr)) { 564 error = ENOTCONN; 565 goto send_release; --- 29 unchanged lines hidden (view full) --- 595{ 596 struct ipxpcb *ipxp = sotoipxpcb(so); 597 598 ipx_setsockaddr(ipxp, nam); 599 return (0); 600} 601 602static int | 564 if (error) { 565 splx(s); 566 goto send_release; 567 } 568 } else { 569 if (ipx_nullhost(ipxp->ipxp_faddr)) { 570 error = ENOTCONN; 571 goto send_release; --- 29 unchanged lines hidden (view full) --- 601{ 602 struct ipxpcb *ipxp = sotoipxpcb(so); 603 604 ipx_setsockaddr(ipxp, nam); 605 return (0); 606} 607 608static int |
603ripx_attach(so, proto) | 609ripx_attach(so, proto, p) |
604 struct socket *so; 605 int proto; | 610 struct socket *so; 611 int proto; |
612 struct proc *p; |
|
606{ 607 int error = 0; 608 int s; 609 struct ipxpcb *ipxp = sotoipxpcb(so); 610 | 613{ 614 int error = 0; 615 int s; 616 struct ipxpcb *ipxp = sotoipxpcb(so); 617 |
611 if (!(so->so_state & SS_PRIV) || (ipxp != NULL)) 612 return (EINVAL); | 618 if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0) 619 return (error); |
613 s = splnet(); | 620 s = splnet(); |
614 error = ipx_pcballoc(so, &ipxrawpcb); | 621 error = ipx_pcballoc(so, &ipxrawpcb, p); |
615 splx(s); 616 if (error) 617 return (error); 618 error = soreserve(so, ipxsendspace, ipxrecvspace); 619 if (error) 620 return (error); 621 ipxp = sotoipxpcb(so); 622 ipxp->ipxp_faddr.x_host = ipx_broadhost; 623 ipxp->ipxp_flags = IPXP_RAWIN | IPXP_RAWOUT; 624 return (error); 625} | 622 splx(s); 623 if (error) 624 return (error); 625 error = soreserve(so, ipxsendspace, ipxrecvspace); 626 if (error) 627 return (error); 628 ipxp = sotoipxpcb(so); 629 ipxp->ipxp_faddr.x_host = ipx_broadhost; 630 ipxp->ipxp_flags = IPXP_RAWIN | IPXP_RAWOUT; 631 return (error); 632} |