The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netiso/iso_pcb.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: iso_pcb.c,v 1.44 2008/04/24 11:38:38 ad Exp $  */
    2 
    3 /*-
    4  * Copyright (c) 1991, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)iso_pcb.c   8.3 (Berkeley) 7/19/94
   32  */
   33 
   34 /***********************************************************
   35                 Copyright IBM Corporation 1987
   36 
   37                       All Rights Reserved
   38 
   39 Permission to use, copy, modify, and distribute this software and its
   40 documentation for any purpose and without fee is hereby granted,
   41 provided that the above copyright notice appear in all copies and that
   42 both that copyright notice and this permission notice appear in
   43 supporting documentation, and that the name of IBM not be
   44 used in advertising or publicity pertaining to distribution of the
   45 software without specific, written prior permission.
   46 
   47 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
   48 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
   49 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
   50 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   51 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
   52 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
   53 SOFTWARE.
   54 
   55 ******************************************************************/
   56 
   57 /*
   58  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
   59  */
   60 /*
   61  * Iso address family net-layer(s) pcb stuff. NEH 1/29/87
   62  */
   63 
   64 #include <sys/cdefs.h>
   65 __KERNEL_RCSID(0, "$NetBSD: iso_pcb.c,v 1.44 2008/04/24 11:38:38 ad Exp $");
   66 
   67 #include "opt_iso.h"
   68 
   69 #ifdef ISO
   70 
   71 #include <sys/param.h>
   72 #include <sys/systm.h>
   73 #include <sys/mbuf.h>
   74 #include <sys/socket.h>
   75 #include <sys/socketvar.h>
   76 #include <sys/errno.h>
   77 #include <sys/proc.h>
   78 #include <sys/kauth.h>
   79 
   80 #include <netiso/argo_debug.h>
   81 #include <netiso/iso.h>
   82 #include <netiso/clnp.h>
   83 #include <netinet/in_systm.h>
   84 #include <net/if.h>
   85 #include <net/route.h>
   86 #include <netiso/iso_pcb.h>
   87 #include <netiso/iso_var.h>
   88 #include <sys/protosw.h>
   89 
   90 const struct iso_addr zeroiso_addr;
   91 
   92 #ifdef ARGO_DEBUG
   93 unsigned char   argo_debug[128];
   94 #endif
   95 
   96 /*
   97  * FUNCTION:            iso_pcballoc
   98  *
   99  * PURPOSE:             creates an isopcb structure in an mbuf,
  100  *                      with socket (so), and
  101  *                      puts it in the queue with head (head)
  102  *
  103  * RETURNS:             0 if OK, ENOBUFS if can't alloc the necessary mbuf
  104  */
  105 int
  106 iso_pcballoc(struct socket *so, void *v)
  107 {
  108         struct isopcb  *head = v;
  109         struct isopcb *isop;
  110 
  111 #ifdef ARGO_DEBUG
  112         if (argo_debug[D_ISO]) {
  113                 printf("iso_pcballoc(so %p)\n", so);
  114         }
  115 #endif
  116         MALLOC(isop, struct isopcb *, sizeof(*isop), M_PCB, M_NOWAIT|M_ZERO);
  117         if (isop == NULL)
  118                 return ENOBUFS;
  119         isop->isop_head = head;
  120         isop->isop_socket = so;
  121         iso_insque(isop, head);
  122         if (so)
  123                 so->so_pcb = isop;
  124         return 0;
  125 }
  126 
  127 /*
  128  * FUNCTION:            iso_pcbbind
  129  *
  130  * PURPOSE:             binds the address given in *(nam) to the socket
  131  *                      specified by the isopcb in *(isop)
  132  *                      If the given address is zero, it makes sure the
  133  *                      address isn't already in use and if it's got a network
  134  *                      portion, we look for an interface with that network
  135  *                      address.  If the address given is zero, we allocate
  136  *                      a port and stuff it in the (nam) structure.
  137  *
  138  * RETURNS:             errno E* or 0 if ok.
  139  *
  140  * SIDE EFFECTS:        increments head->isop_lport if it allocates a port #
  141  *
  142  * NOTES:
  143  */
  144 int
  145 iso_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
  146 {
  147         struct isopcb *isop = v;
  148         struct isopcb *head = isop->isop_head;
  149         struct sockaddr_iso *siso;
  150         struct iso_ifaddr *ia;
  151         union {
  152                 char            data[2];
  153                 u_short         s;
  154         } suf;
  155 
  156 #ifdef ARGO_DEBUG
  157         if (argo_debug[D_ISO]) {
  158                 printf("iso_pcbbind(isop %p, nam %p)\n", isop, nam);
  159         }
  160 #endif
  161         suf.s = 0;
  162         if (iso_ifaddr.tqh_first == 0)  /* any interfaces attached? */
  163                 return EADDRNOTAVAIL;
  164         if (isop->isop_laddr)   /* already bound */
  165                 return EADDRINUSE;
  166         if (nam == (struct mbuf *) 0) {
  167                 isop->isop_laddr = &isop->isop_sladdr;
  168                 isop->isop_sladdr.siso_len = sizeof(struct sockaddr_iso);
  169                 isop->isop_sladdr.siso_family = AF_ISO;
  170                 isop->isop_sladdr.siso_tlen = 2;
  171                 isop->isop_sladdr.siso_nlen = 0;
  172                 isop->isop_sladdr.siso_slen = 0;
  173                 isop->isop_sladdr.siso_plen = 0;
  174                 goto noname;
  175         }
  176         siso = mtod(nam, struct sockaddr_iso *);
  177 #ifdef ARGO_DEBUG
  178         if (argo_debug[D_ISO]) {
  179                 printf("iso_pcbbind(name len 0x%x)\n", nam->m_len);
  180                 printf("The address is %s\n", clnp_iso_addrp(&siso->siso_addr));
  181         }
  182 #endif
  183         /*
  184          * We would like sort of length check but since some OSI addrs
  185          * do not have fixed length, we can't really do much.
  186          * The ONLY thing we can say is that an osi addr has to have
  187          * at LEAST an afi and one more byte and had better fit into
  188          * a struct iso_addr.
  189          * However, in fact the size of the whole thing is a struct
  190          * sockaddr_iso, so probably this is what we should check for.
  191          */
  192         if ((nam->m_len < 2) || (nam->m_len < siso->siso_len)) {
  193                 return ENAMETOOLONG;
  194         }
  195         if (siso->siso_nlen) {
  196                 /* non-zero net addr- better match one of our interfaces */
  197 #ifdef ARGO_DEBUG
  198                 if (argo_debug[D_ISO]) {
  199                         printf("iso_pcbbind: bind to NOT zeroisoaddr\n");
  200                 }
  201 #endif
  202                 for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
  203                         if (SAME_ISOIFADDR(siso, &ia->ia_addr))
  204                                 break;
  205                 if (ia == 0)
  206                         return EADDRNOTAVAIL;
  207         }
  208         if (siso->siso_len <= sizeof(isop->isop_sladdr)) {
  209                 isop->isop_laddr = &isop->isop_sladdr;
  210         } else {
  211                 if ((nam = m_copy(nam, 0, (int) M_COPYALL)) == 0)
  212                         return ENOBUFS;
  213                 isop->isop_mladdr = nam;
  214                 isop->isop_laddr = mtod(nam, struct sockaddr_iso *);
  215         }
  216         bcopy((void *) siso, (void *) isop->isop_laddr, siso->siso_len);
  217         if (siso->siso_tlen == 0)
  218                 goto noname;
  219         if ((isop->isop_socket->so_options & SO_REUSEADDR) == 0 &&
  220             iso_pcblookup(head, 0, (void *) 0, isop->isop_laddr))
  221                 return EADDRINUSE;
  222         if (siso->siso_tlen <= 2) {
  223                 bcopy(TSEL(siso), suf.data, sizeof(suf.data));
  224                 suf.s = ntohs(suf.s);
  225                 if (suf.s < ISO_PORT_RESERVED &&
  226                     (l == NULL || kauth_authorize_generic(l->l_cred,
  227                      KAUTH_GENERIC_ISSUSER, NULL)))
  228                         return EACCES;
  229         } else {
  230                 char  *cp;
  231 noname:
  232                 cp = WRITABLE_TSEL(isop->isop_laddr);
  233                 isop->isop_laddr->siso_tlen = 2;
  234 #ifdef ARGO_DEBUG
  235                 if (argo_debug[D_ISO]) {
  236                         printf("iso_pcbbind noname\n");
  237                 }
  238 #endif
  239                 do {
  240                         if (head->isop_lport++ < ISO_PORT_RESERVED ||
  241                             head->isop_lport > ISO_PORT_USERRESERVED)
  242                                 head->isop_lport = ISO_PORT_RESERVED;
  243                         suf.s = htons(head->isop_lport);
  244                         cp[0] = suf.data[0];
  245                         cp[1] = suf.data[1];
  246                 } while (iso_pcblookup(head, 0, (void *) 0, isop->isop_laddr));
  247         }
  248 #ifdef ARGO_DEBUG
  249         if (argo_debug[D_ISO]) {
  250                 printf("iso_pcbbind returns 0, suf 0x%x\n", suf.s);
  251         }
  252 #endif
  253         return 0;
  254 }
  255 /*
  256  * FUNCTION:            iso_pcbconnect
  257  *
  258  * PURPOSE:             Make the isopcb (isop) look like it's connected.
  259  *                      In other words, give it the peer address given in
  260  *                      the mbuf * (nam).   Make sure such a combination
  261  *                      of local, peer addresses doesn't already exist
  262  *                      for this protocol.  Internet mentality prevails here,
  263  *                      wherein a src,dst pair uniquely identifies a connection.
  264  *                      Both net address and port must be specified in argument
  265  *                      (nam).
  266  *                      If we don't have a local address for this socket yet,
  267  *                      we pick one by calling iso_pcbbind().
  268  *
  269  * RETURNS:             errno E* or 0 if ok.
  270  *
  271  * SIDE EFFECTS:        Looks up a route, which may cause one to be left
  272  *                      in the isopcb.
  273  *
  274  * NOTES:
  275  */
  276 int
  277 iso_pcbconnect(void *v, struct mbuf *nam, struct lwp *l)
  278 {
  279         struct isopcb *isop = v;
  280         struct sockaddr_iso *siso = mtod(nam, struct sockaddr_iso *);
  281         int             local_zero, error = 0;
  282         struct iso_ifaddr *ia;
  283 
  284 #ifdef ARGO_DEBUG
  285         if (argo_debug[D_ISO]) {
  286                 printf("iso_pcbconnect(isop %p sock %p nam %p",
  287                     isop, isop->isop_socket, nam);
  288                 printf("nam->m_len 0x%x), addr:\n", nam->m_len);
  289                 dump_isoaddr(siso);
  290         }
  291 #endif
  292         if (nam->m_len < siso->siso_len)
  293                 return EINVAL;
  294         if (siso->siso_family != AF_ISO)
  295                 return EAFNOSUPPORT;
  296         if (siso->siso_nlen == 0) {
  297                 if ((ia = iso_ifaddr.tqh_first) != NULL) {
  298                         int             nlen = ia->ia_addr.siso_nlen;
  299                         char *tmp;
  300                         tmp = WRITABLE_TSEL(siso);
  301                         memmove(tmp + nlen, TSEL(siso),
  302                             siso->siso_plen + siso->siso_tlen +
  303                             siso->siso_slen);
  304                         bcopy((void *) & ia->ia_addr.siso_addr,
  305                               (void *) & siso->siso_addr, nlen + 1);
  306                         /* includes siso->siso_nlen = nlen; */
  307                 } else
  308                         return EADDRNOTAVAIL;
  309         }
  310         /*
  311          * Local zero means either not bound, or bound to a TSEL, but no
  312          * particular local interface.  So, if we want to send somebody
  313          * we need to choose a return address.
  314          */
  315         local_zero =
  316                 ((isop->isop_laddr == 0) || (isop->isop_laddr->siso_nlen == 0));
  317         if (local_zero) {
  318                 int             flags;
  319 
  320 #ifdef ARGO_DEBUG
  321                 if (argo_debug[D_ISO]) {
  322                         printf("iso_pcbconnect localzero 1\n");
  323                 }
  324 #endif
  325                 /*
  326                  * If route is known or can be allocated now, our src addr is
  327                  * taken from the i/f, else punt.
  328                  */
  329                 flags = isop->isop_socket->so_options & SO_DONTROUTE;
  330                 error = clnp_route(&siso->siso_addr, &isop->isop_route, flags,
  331                                    NULL, &ia);
  332                 if (error)
  333                         return error;
  334 #ifdef ARGO_DEBUG
  335                 if (argo_debug[D_ISO]) {
  336                         printf("iso_pcbconnect localzero 2, rt %p",
  337                                rtcache_validate(&isop->isop_route));
  338                         printf(" ia %p\n", ia);
  339                 }
  340 #endif
  341         }
  342 #ifdef ARGO_DEBUG
  343         if (argo_debug[D_ISO]) {
  344                 printf("in iso_pcbconnect before lookup isop %p isop->sock %p\n",
  345                        isop, isop->isop_socket);
  346         }
  347 #endif
  348         if (local_zero) {
  349                 int             nlen, tlen, totlen;
  350                 void *newtsel;
  351                 const void *oldtsel;
  352                 siso = isop->isop_laddr;
  353                 if (siso == 0 || siso->siso_tlen == 0)
  354                         (void) iso_pcbbind(isop, (struct mbuf *)0,
  355                             (struct lwp *)0);
  356                 /*
  357                  * Here we have problem of squezeing in a definite network address
  358                  * into an existing sockaddr_iso, which in fact may not have room
  359                  * for it.  This gets messy.
  360                  */
  361                 siso = isop->isop_laddr;
  362                 oldtsel = TSEL(siso);
  363                 tlen = siso->siso_tlen;
  364                 nlen = ia->ia_addr.siso_nlen;
  365                 totlen = tlen + nlen + offsetof(struct sockaddr_iso, siso_data[0]);
  366                 if ((siso == &isop->isop_sladdr) &&
  367                     (totlen > sizeof(isop->isop_sladdr))) {
  368                         struct mbuf    *m = m_get(M_DONTWAIT, MT_SONAME);
  369                         if (m == 0)
  370                                 return ENOBUFS;
  371                         m->m_len = totlen;
  372                         isop->isop_mladdr = m;
  373                         isop->isop_laddr = siso = mtod(m, struct sockaddr_iso *);
  374                 }
  375                 siso->siso_nlen = ia->ia_addr.siso_nlen;
  376                 newtsel = WRITABLE_TSEL(siso);
  377                 memmove(newtsel, oldtsel, tlen);
  378                 bcopy(ia->ia_addr.siso_data, siso->siso_data, nlen);
  379                 siso->siso_tlen = tlen;
  380                 siso->siso_family = AF_ISO;
  381                 siso->siso_len = totlen;
  382                 siso = mtod(nam, struct sockaddr_iso *);
  383         }
  384 #ifdef ARGO_DEBUG
  385         if (argo_debug[D_ISO]) {
  386                 printf("in iso_pcbconnect before bcopy isop %p isop->sock %p\n",
  387                     isop, isop->isop_socket);
  388         }
  389 #endif
  390         /*
  391          * If we had to allocate space to a previous big foreign address,
  392          * and for some reason we didn't free it, we reuse it knowing
  393          * that is going to be big enough, as sockaddrs are delivered in
  394          * 128 byte mbufs.
  395          * If the foreign address is small enough, we use default space;
  396          * otherwise, we grab an mbuf to copy into.
  397          */
  398         if (isop->isop_faddr == 0 || isop->isop_faddr == &isop->isop_sfaddr) {
  399                 if (siso->siso_len <= sizeof(isop->isop_sfaddr))
  400                         isop->isop_faddr = &isop->isop_sfaddr;
  401                 else {
  402                         struct mbuf    *m = m_get(M_DONTWAIT, MT_SONAME);
  403                         if (m == 0)
  404                                 return ENOBUFS;
  405                         isop->isop_mfaddr = m;
  406                         isop->isop_faddr = mtod(m, struct sockaddr_iso *);
  407                 }
  408         }
  409         bcopy((void *) siso, (void *) isop->isop_faddr, siso->siso_len);
  410 #ifdef ARGO_DEBUG
  411         if (argo_debug[D_ISO]) {
  412                 printf("in iso_pcbconnect after bcopy isop %p isop->sock %p\n",
  413                     isop, isop->isop_socket);
  414                 printf("iso_pcbconnect connected to addr:\n");
  415                 dump_isoaddr(isop->isop_faddr);
  416                 printf("iso_pcbconnect end: src addr:\n");
  417                 dump_isoaddr(isop->isop_laddr);
  418         }
  419 #endif
  420         return 0;
  421 }
  422 
  423 /*
  424  * FUNCTION:            iso_pcbdisconnect()
  425  *
  426  * PURPOSE:             washes away the peer address info so the socket
  427  *                      appears to be disconnected.
  428  *                      If there's no file descriptor associated with the socket
  429  *                      it detaches the pcb.
  430  *
  431  * RETURNS:             Nada.
  432  *
  433  * SIDE EFFECTS:        May detach the pcb.
  434  *
  435  * NOTES:
  436  */
  437 void
  438 iso_pcbdisconnect(void *v)
  439 {
  440         struct isopcb  *isop = v;
  441         struct sockaddr_iso *siso;
  442 
  443 #ifdef ARGO_DEBUG
  444         if (argo_debug[D_ISO]) {
  445                 printf("iso_pcbdisconnect(isop %p)\n", isop);
  446         }
  447 #endif
  448         /*
  449          * Preserver binding infnormation if already bound.
  450          */
  451         if ((siso = isop->isop_laddr) && siso->siso_nlen && siso->siso_tlen) {
  452                 const void *otsel = TSEL(siso);
  453                 siso->siso_nlen = 0;
  454                 memmove(WRITABLE_TSEL(siso), otsel, siso->siso_tlen);
  455         }
  456         if (isop->isop_faddr && isop->isop_faddr != &isop->isop_sfaddr)
  457                 m_freem(isop->isop_mfaddr);
  458         isop->isop_faddr = 0;
  459         if (isop->isop_socket->so_state & SS_NOFDREF)
  460                 iso_pcbdetach(isop);
  461 }
  462 
  463 /*
  464  * FUNCTION:            iso_pcbdetach
  465  *
  466  * PURPOSE:             detach the pcb at *(isop) from it's socket and free
  467  *                      the mbufs associated with the pcb..
  468  *                      Dequeues (isop) from its head.
  469  *
  470  * RETURNS:             Nada.
  471  *
  472  * SIDE EFFECTS:
  473  *
  474  * NOTES:
  475  */
  476 void
  477 iso_pcbdetach(void *v)
  478 {
  479         struct isopcb  *isop = v;
  480         struct socket  *so = isop->isop_socket;
  481 
  482 #ifdef ARGO_DEBUG
  483         if (argo_debug[D_ISO]) {
  484                 printf("iso_pcbdetach(isop %p socket %p so %p)\n",
  485                     isop, isop->isop_socket, so);
  486         }
  487 #endif
  488         if (so) {               /* in the x.25 domain, we sometimes have no
  489                                  * socket */
  490                 so->so_pcb = 0;
  491                 /* sofree drops the lock */
  492                 sofree(so);
  493                 mutex_enter(softnet_lock);
  494         }
  495 #ifdef ARGO_DEBUG
  496         if (argo_debug[D_ISO]) {
  497                 printf("iso_pcbdetach 2 \n");
  498         }
  499 #endif
  500         if (isop->isop_options)
  501                 (void) m_free(isop->isop_options);
  502 #ifdef ARGO_DEBUG
  503         if (argo_debug[D_ISO]) {
  504                 printf("iso_pcbdetach 3 \n");
  505         }
  506 #endif
  507         rtcache_free(&isop->isop_route);
  508 #ifdef ARGO_DEBUG
  509         if (argo_debug[D_ISO]) {
  510                 printf("iso_pcbdetach 3.1\n");
  511         }
  512 #endif
  513         if (isop->isop_clnpcache != NULL) {
  514                 struct clnp_cache *clcp =
  515                 mtod(isop->isop_clnpcache, struct clnp_cache *);
  516 #ifdef ARGO_DEBUG
  517                 if (argo_debug[D_ISO]) {
  518                         printf("iso_pcbdetach 3.2: clcp %p freeing clc_hdr %p\n",
  519                             clcp, clcp->clc_hdr);
  520                 }
  521 #endif
  522                 if (clcp->clc_hdr != NULL)
  523                         m_free(clcp->clc_hdr);
  524 #ifdef ARGO_DEBUG
  525                 if (argo_debug[D_ISO]) {
  526                         printf("iso_pcbdetach 3.3: freeing cache %p\n",
  527                             isop->isop_clnpcache);
  528                 }
  529 #endif
  530                 m_free(isop->isop_clnpcache);
  531         }
  532 #ifdef ARGO_DEBUG
  533         if (argo_debug[D_ISO]) {
  534                 printf("iso_pcbdetach 4 \n");
  535         }
  536 #endif
  537         iso_remque(isop);
  538 #ifdef ARGO_DEBUG
  539         if (argo_debug[D_ISO]) {
  540                 printf("iso_pcbdetach 5 \n");
  541         }
  542 #endif
  543         if (isop->isop_laddr && (isop->isop_laddr != &isop->isop_sladdr))
  544                 m_freem(isop->isop_mladdr);
  545         free((void *) isop, M_PCB);
  546 }
  547 
  548 
  549 /*
  550  * FUNCTION:            iso_pcbnotify
  551  *
  552  * PURPOSE:             notify all connections in this protocol's queue (head)
  553  *                      that have peer address (dst) of the problem (errno)
  554  *                      by calling (notify) on the connections' isopcbs.
  555  *
  556  * RETURNS:             Rien.
  557  *
  558  * SIDE EFFECTS:
  559  *
  560  * NOTES:               (notify) is called at splnet!
  561  */
  562 void
  563 iso_pcbnotify(struct isopcb *head, const struct sockaddr_iso *siso, int errno,
  564         void (*notify) (struct isopcb *))
  565 {
  566         struct isopcb *isop;
  567         int s = splnet();
  568 
  569 #ifdef ARGO_DEBUG
  570         if (argo_debug[D_ISO]) {
  571                 printf("iso_pcbnotify(head %p, notify %p) dst:\n",
  572                         head, notify);
  573         }
  574 #endif
  575         for (isop = head->isop_next; isop != head; isop = isop->isop_next) {
  576                 if (isop->isop_socket == 0 || isop->isop_faddr == 0 ||
  577                     !SAME_ISOADDR(siso, isop->isop_faddr)) {
  578 #ifdef ARGO_DEBUG
  579                         if (argo_debug[D_ISO]) {
  580                                 printf("iso_pcbnotify: CONTINUE isop %p, sock %p\n",
  581                                     isop, isop->isop_socket);
  582                                 printf("addrmatch cmp'd with (%p):\n",
  583                                         isop->isop_faddr);
  584                                 dump_isoaddr(isop->isop_faddr);
  585                         }
  586 #endif
  587                         continue;
  588                 }
  589                 if (errno)
  590                         isop->isop_socket->so_error = errno;
  591                 if (notify)
  592                         (*notify) (isop);
  593         }
  594         splx(s);
  595 #ifdef ARGO_DEBUG
  596         if (argo_debug[D_ISO]) {
  597                 printf("END OF iso_pcbnotify\n");
  598         }
  599 #endif
  600 }
  601 
  602 
  603 /*
  604  * FUNCTION:            iso_pcblookup
  605  *
  606  * PURPOSE:             looks for a given combination of (faddr), (fport),
  607  *                      (lport), (laddr) in the queue named by (head).
  608  *                      Argument (flags) is ignored.
  609  *
  610  * RETURNS:             ptr to the isopcb if it finds a connection matching
  611  *                      these arguments, o.w. returns zero.
  612  *
  613  * SIDE EFFECTS:
  614  *
  615  * NOTES:
  616  */
  617 struct isopcb  *
  618 iso_pcblookup(
  619         struct isopcb  *head,
  620         int             fportlen,
  621         void *        fport,
  622         const struct sockaddr_iso *laddr)
  623 {
  624         struct isopcb *isop;
  625         const void *lp = TSEL(laddr);
  626         unsigned int    llen = laddr->siso_tlen;
  627 
  628 #ifdef ARGO_DEBUG
  629         if (argo_debug[D_ISO]) {
  630                 printf("iso_pcblookup(head %p laddr %p fport %p)\n",
  631                        head, laddr, fport);
  632         }
  633 #endif
  634         for (isop = head->isop_next; isop != head; isop = isop->isop_next) {
  635                 if (isop->isop_laddr == 0 || isop->isop_laddr == laddr)
  636                         continue;
  637                 if (isop->isop_laddr->siso_tlen != llen)
  638                         continue;
  639                 if (bcmp(lp, TSEL(isop->isop_laddr), llen))
  640                         continue;
  641                 if (fportlen && isop->isop_faddr &&
  642                     bcmp(fport, TSEL(isop->isop_faddr), (unsigned) fportlen))
  643                         continue;
  644                 /*
  645                  * PHASE2 addrmatch1 should be iso_addrmatch(a, b, mask)
  646                  * where mask is taken from isop->isop_laddrmask (new field)
  647                  * isop_lnetmask will also be available in isop if (laddr !=
  648                  * &zeroiso_addr && !iso_addrmatch1(laddr,
  649                  * &(isop->isop_laddr.siso_addr))) continue;
  650                  */
  651                 if (laddr->siso_nlen && (!SAME_ISOADDR(laddr, isop->isop_laddr)))
  652                         continue;
  653                 return (isop);
  654         }
  655         return (struct isopcb *) 0;
  656 }
  657 #endif /* ISO */

Cache object: f20bd55e9c80070a0480e016c6e449f3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.