]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netat/ddp_usrreq.c
xnu-1228.tar.gz
[apple/xnu.git] / bsd / netat / ddp_usrreq.c
index fde242f787bb7d9e7a837098e07e8e5b51da1584..fd6b8ab92ee31bbe3319ff56087e0bc32c40519a 100644 (file)
@@ -1,31 +1,29 @@
 /*
- * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This file contains Original Code and/or Modifications of Original Code 
- * as defined in and that are subject to the Apple Public Source License 
- * Version 2.0 (the 'License'). You may not use this file except in 
- * compliance with the License.  The rights granted to you under the 
- * License may not be used to create, or enable the creation or 
- * redistribution of, unlawful or unlicensed copies of an Apple operating 
- * system, or to circumvent, violate, or enable the circumvention or 
- * violation of, any terms of an Apple operating system software license 
- * agreement.
- *
- * Please obtain a copy of the License at 
- * http://www.opensource.apple.com/apsl/ and read it before using this 
- * file.
- *
- * The Original Code and all software distributed under the License are 
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
- * Please see the License for the specific language governing rights and 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
  * limitations under the License.
- *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  *     Copyright (c) 1998 Apple Computer, Inc. 
 
 #include <net/if.h>
 
+#include <netat/sysglue.h>
 #include <netat/appletalk.h>
+#include <netat/at_pcb.h>
 #include <netat/at_var.h>
-#include <netat/sysglue.h>
 #include <netat/ddp.h>
 #include <netat/ep.h>
 #include <netat/rtmp.h>
 #include <netat/zip.h>
-#include <netat/at_pcb.h>
 #include <netat/routing_tables.h>
 #include <netat/nbp.h>
 
-extern int at_control(), at_memzone_init();
-extern void  nbp_input(), ep_input(), zip_router_input(), 
-  sip_input(), add_ddp_handler(), init_ddp_handler(), 
-  ddp_start(), ddp_input(), appletalk_hack_start();
-extern u_short ddp_checksum();
-extern at_ifaddr_t *forUs();
-extern struct mbuf *m_dup(struct mbuf *, int);
 
 extern at_ifaddr_t *ifID_home;
 extern int xpatcnt;
@@ -79,26 +70,23 @@ u_long ddp_sendspace = 600, /* *** what should this value be? *** */
   ddp_recvspace = 50 * (600 + sizeof(struct sockaddr_at));
 
 int ddp_pru_control(struct socket *so, u_long cmd, caddr_t data,
-               struct ifnet *ifp, struct proc *p)
+               struct ifnet *ifp, __unused struct proc *p)
 {
        return(at_control(so, cmd, data, ifp));
 }
 
 
 int    ddp_pru_attach(struct socket *so, int proto,
-                  struct proc *p)
+                  __unused struct proc *p)
 {
-       int s, error = 0;
-       at_ddp_t *ddp = NULL;
+       int error = 0;
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
 
         error = soreserve(so, ddp_sendspace, ddp_recvspace);
        if (error != 0)
                return error;
 
-       s = splnet();
        error = at_pcballoc(so, &ddp_head);
-       splx(s);
        if (error)
                return error;
        pcb = (struct atpcb *)((so)->so_pcb);
@@ -113,8 +101,7 @@ int ddp_pru_attach(struct socket *so, int proto,
 int  ddp_pru_disconnect(struct socket *so)
 {
 
-       int s, error = 0;
-       at_ddp_t *ddp = NULL;
+       int error = 0;
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
 
        if (pcb == NULL) 
@@ -124,9 +111,7 @@ int  ddp_pru_disconnect(struct socket *so)
                return ENOTCONN;
 
        soisdisconnected(so);
-       s = splnet();
        at_pcbdetach(pcb);
-       splx(s);
 
        return error;
 }
@@ -134,31 +119,25 @@ int  ddp_pru_disconnect(struct socket *so)
 
 int  ddp_pru_abort(struct socket *so)
 {
-       int s;
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
 
        if (pcb == NULL) 
                return (EINVAL);
 
        soisdisconnected(so);
-       s = splnet();
        at_pcbdetach(pcb);
-       splx(s);
 
        return 0;
 }
 
 int  ddp_pru_detach(struct socket *so)
 {
-       int s;
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
 
        if (pcb == NULL) 
                return (EINVAL);
 
-       s = splnet();
        at_pcbdetach(pcb);
-       splx(s);
        return 0;
 }
                                          
@@ -175,7 +154,7 @@ int ddp_pru_shutdown(struct socket *so)
                                          
 
 int    ddp_pru_bind(struct socket *so, struct sockaddr *nam,
-               struct proc *p)
+               __unused struct proc *p)
 {
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
 
@@ -186,9 +165,9 @@ int    ddp_pru_bind(struct socket *so, struct sockaddr *nam,
 }
 
 
-int    ddp_pru_send(struct socket *so, int flags, struct mbuf *m, 
-                    struct sockaddr *addr, struct mbuf *control,
-                    struct proc *p)
+int    ddp_pru_send(struct socket *so, __unused int flags, struct mbuf *m, 
+                    struct sockaddr *addr, __unused struct mbuf *control,
+                    __unused struct proc *p)
 {
        at_ddp_t *ddp = NULL;
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
@@ -231,8 +210,8 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m,
                }
        }
        if (ddp) {
-               ddp->length = m->m_pkthdr.len;
-               UAS_ASSIGN(ddp->checksum, 
+               DDPLEN_ASSIGN(ddp, m->m_pkthdr.len);
+               UAS_ASSIGN_HTON(ddp->checksum, 
                           (pcb->ddp_flags & DDPFLG_CHKSUM)? 1: 0);
                ddp->type = (pcb->ddptype)? pcb->ddptype: DEFAULT_OT_DDPTYPE;
 #ifdef NOT_YET
@@ -261,8 +240,8 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m,
                        NET_ASSIGN(ddp->src_net, ifID->ifThisNode.s_net);
                        ddp->src_node = ifID->ifThisNode.s_node;
                        ddp->src_socket = pcb->lport;
-                       if (UAS_VALUE(ddp->checksum))
-                               UAS_ASSIGN(ddp->checksum, ddp_checksum(m, 4));
+                       if (UAS_VALUE_NTOH(ddp->checksum))
+                               UAS_ASSIGN_HTON(ddp->checksum, ddp_checksum(m, 4));
                        ddp_input(n, ifID);
                }
        }
@@ -272,7 +251,6 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m,
 int   ddp_pru_sockaddr(struct socket *so, 
                   struct sockaddr **nam)
 {
-        int s;
        struct atpcb *pcb;
        struct sockaddr_at *sat;
 
@@ -281,9 +259,7 @@ int   ddp_pru_sockaddr(struct socket *so,
                return(ENOMEM);
        bzero((caddr_t)sat, sizeof(*sat));
 
-       s = splnet();
        if ((pcb = sotoatpcb(so)) == NULL) {
-               splx(s);
                FREE(sat, M_SONAME);
                return(EINVAL);
        }
@@ -292,7 +268,6 @@ int   ddp_pru_sockaddr(struct socket *so,
        sat->sat_len = sizeof(*sat);
        sat->sat_port = pcb->lport;
        sat->sat_addr = pcb->laddr;
-       splx(s);
 
        *nam = (struct sockaddr *)sat;
        return(0);
@@ -302,7 +277,6 @@ int   ddp_pru_sockaddr(struct socket *so,
 int  ddp_pru_peeraddr(struct socket *so, 
                  struct sockaddr **nam)
 {
-        int s;
        struct atpcb *pcb;
        struct sockaddr_at *sat;
 
@@ -311,9 +285,7 @@ int  ddp_pru_peeraddr(struct socket *so,
                return (ENOMEM);
        bzero((caddr_t)sat, sizeof(*sat));
 
-       s = splnet();
        if ((pcb = sotoatpcb(so)) == NULL) {
-               splx(s);
                FREE(sat, M_SONAME);
                return(EINVAL);
        }
@@ -322,15 +294,14 @@ int  ddp_pru_peeraddr(struct socket *so,
        sat->sat_len = sizeof(*sat);
        sat->sat_port = pcb->rport;
        sat->sat_addr = pcb->raddr;
-       splx(s);
 
        *nam = (struct sockaddr *)sat;
        return(0);
 }
 
 
-int    ddp_pru_connect(struct socket *so, struct sockaddr *nam,
-                  struct proc *p)
+int ddp_pru_connect(struct socket *so, struct sockaddr *nam,
+                  __unused struct proc *p)
 {
        struct atpcb *pcb = (struct atpcb *)((so)->so_pcb);
        struct sockaddr_at *faddr = (struct sockaddr_at *) nam;
@@ -350,7 +321,6 @@ int    ddp_pru_connect(struct socket *so, struct sockaddr *nam,
 }
 
 
-
 /*
  * One-time AppleTalk initialization
  */
@@ -370,4 +340,3 @@ void ddp_init()
 
        appletalk_hack_start();
 } /* ddp_init */
-