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/netatalk/at_proto.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: at_proto.c,v 1.16 2008/04/24 11:38:37 ad Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1990,1991 Regents of The University of Michigan.
    5  * All Rights Reserved.
    6  *
    7  * Permission to use, copy, modify, and distribute this software and
    8  * its documentation for any purpose and without fee is hereby granted,
    9  * provided that the above copyright notice appears in all copies and
   10  * that both that copyright notice and this permission notice appear
   11  * in supporting documentation, and that the name of The University
   12  * of Michigan not be used in advertising or publicity pertaining to
   13  * distribution of the software without specific, written prior
   14  * permission. This software is supplied as is without expressed or
   15  * implied warranties of any kind.
   16  *
   17  * This product includes software developed by the University of
   18  * California, Berkeley and its contributors.
   19  *
   20  *      Research Systems Unix Group
   21  *      The University of Michigan
   22  *      c/o Wesley Craig
   23  *      535 W. William Street
   24  *      Ann Arbor, Michigan
   25  *      +1-313-764-2278
   26  *      netatalk@umich.edu
   27  */
   28 
   29 #include <sys/cdefs.h>
   30 __KERNEL_RCSID(0, "$NetBSD: at_proto.c,v 1.16 2008/04/24 11:38:37 ad Exp $");
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/protosw.h>
   35 #include <sys/domain.h>
   36 #include <sys/socket.h>
   37 
   38 #include <sys/kernel.h>
   39 #include <net/if.h>
   40 #include <net/radix.h>
   41 #include <net/if_ether.h>
   42 #include <netinet/in.h>
   43 #include <net/route.h>
   44 
   45 #include <netatalk/at.h>
   46 #include <netatalk/ddp.h>
   47 #include <netatalk/at_var.h>
   48 #include <netatalk/ddp_var.h>
   49 #include <netatalk/at_extern.h>
   50 
   51 DOMAIN_DEFINE(atalkdomain);     /* forward declare and add to link set */
   52 
   53 PR_WRAP_USRREQ(ddp_usrreq)
   54 #define ddp_usrreq      ddp_usrreq_wrapper
   55 
   56 const struct protosw atalksw[] = {
   57     {
   58         .pr_type = SOCK_DGRAM,
   59         .pr_domain = &atalkdomain,
   60         .pr_protocol = ATPROTO_DDP,
   61         .pr_flags = PR_ATOMIC|PR_ADDR,
   62         .pr_output = ddp_output,
   63         .pr_usrreq = ddp_usrreq,
   64         .pr_init = ddp_init,
   65     },
   66 };
   67 
   68 struct domain atalkdomain = {
   69         .dom_family = PF_APPLETALK,
   70         .dom_name = "appletalk",
   71         .dom_init = NULL,
   72         .dom_externalize = NULL,
   73         .dom_dispose = NULL,
   74         .dom_protosw = atalksw,
   75         .dom_protoswNPROTOSW = &atalksw[__arraycount(atalksw)],
   76         .dom_rtattach = rn_inithead,
   77         .dom_rtoffset = 32,
   78         .dom_maxrtkey = sizeof(struct sockaddr_at),
   79         .dom_ifattach = NULL,
   80         .dom_ifdetach = NULL,
   81         .dom_ifqueues = { &atintrq1, &atintrq2 },
   82         .dom_link = { NULL },
   83         .dom_mowner = MOWNER_INIT("",""),
   84         .dom_sa_cmpofs = offsetof(struct sockaddr_at, sat_addr),
   85         .dom_sa_cmplen = sizeof(struct at_addr),
   86         .dom_rtcache = LIST_HEAD_INITIALIZER(atalkdomain.dom_rtcache)
   87 };
   88 
   89 int
   90 sockaddr_at_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
   91 {
   92         int rc;
   93         uint_fast8_t len;
   94         const uint_fast8_t addrofs = offsetof(struct sockaddr_at, sat_addr),
   95                            addrend = addrofs + sizeof(struct at_addr);
   96         const struct sockaddr_at *sat1, *sat2;
   97 
   98         sat1 = satocsat(sa1);
   99         sat2 = satocsat(sa2);
  100 
  101         len = MIN(addrend, MIN(sat1->sat_len, sat2->sat_len));
  102 
  103         if (len > addrofs &&
  104             (rc = memcmp(&sat1->sat_addr, &sat2->sat_addr, len - addrofs)) != 0)
  105                 return rc;
  106 
  107         return sat1->sat_len - sat2->sat_len;
  108 }

Cache object: 25001f696b6a0997a44330bf8f26b6ce


[ 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.