]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netat/aurp_aurpd.c
xnu-2050.48.11.tar.gz
[apple/xnu.git] / bsd / netat / aurp_aurpd.c
index 757aa3188d1b0e62b79d58bf37be69389fb54475..1fed65a63fb8a0fc844933c8d242fac8ecb72bdf 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -38,6 +38,7 @@
  * Kernel process to implement the AURP daemon:
  *  manage tunnels to remote AURP servers across IP networks
  */
  * Kernel process to implement the AURP daemon:
  *  manage tunnels to remote AURP servers across IP networks
  */
+#ifdef AURP_SUPPORT
 
 #include <sys/errno.h>
 #include <sys/types.h>
 
 #include <sys/errno.h>
 #include <sys/types.h>
@@ -62,6 +63,7 @@
 
 #include <netat/sysglue.h>
 #include <netat/appletalk.h>
 
 #include <netat/sysglue.h>
 #include <netat/appletalk.h>
+#include <netat/at_pcb.h>
 #include <netat/at_var.h>
 #include <netat/routing_tables.h>
 #include <netat/at_pcb.h>
 #include <netat/at_var.h>
 #include <netat/routing_tables.h>
 #include <netat/at_pcb.h>
@@ -109,7 +111,6 @@ aurpd_start()
         */
        bzero((char *)&aurp_global.tunnel, sizeof(aurp_global.tunnel));
        /*lock_alloc(&aurp_global.glock, LOCK_ALLOC_PIN, AURP_EVNT_LOCK, -1);*/
         */
        bzero((char *)&aurp_global.tunnel, sizeof(aurp_global.tunnel));
        /*lock_alloc(&aurp_global.glock, LOCK_ALLOC_PIN, AURP_EVNT_LOCK, -1);*/
-       ATLOCKINIT(aurp_global.glock);
        ATEVENTINIT(aurp_global.event_anchor);
 
        /* open udp socket */
        ATEVENTINIT(aurp_global.event_anchor);
 
        /* open udp socket */
@@ -150,7 +151,7 @@ aurpd_start()
                sopt.sopt_level   = SOL_SOCKET;
                sopt.sopt_name    = SO_RCVBUF;
                sopt.sopt_dir     = SOPT_SET;
                sopt.sopt_level   = SOL_SOCKET;
                sopt.sopt_name    = SO_RCVBUF;
                sopt.sopt_dir     = SOPT_SET;
-               sopt.sopt_p               = NULL;
+               sopt.sopt_p       = kernproc;
                if ((error = sosetopt(so, &sopt)) != 0)
                        goto out;
        }
                if ((error = sosetopt(so, &sopt)) != 0)
                        goto out;
        }
@@ -170,7 +171,7 @@ aurpd_start()
                sopt.sopt_level   = SOL_SOCKET;
                sopt.sopt_name    = SO_SNDBUF;
                sopt.sopt_dir     = SOPT_SET;
                sopt.sopt_level   = SOL_SOCKET;
                sopt.sopt_name    = SO_SNDBUF;
                sopt.sopt_dir     = SOPT_SET;
-               sopt.sopt_p               = NULL;
+               sopt.sopt_p       = kernproc;
                if ((error = sosetopt(so, &sopt)) != 0)
                        goto out;
        }
                if ((error = sosetopt(so, &sopt)) != 0)
                        goto out;
        }
@@ -209,7 +210,6 @@ AURPgetmsg(err)
                 *           when a packet arrives
                 */
 
                 *           when a packet arrives
                 */
 
-               ATDISABLE(s, aurp_global.glock);
                events = aurp_global.event;
                if (((*err == 0) || (*err == EWOULDBLOCK)) && events == 0)
                  {
                events = aurp_global.event;
                if (((*err == 0) || (*err == EWOULDBLOCK)) && events == 0)
                  {
@@ -218,7 +218,6 @@ AURPgetmsg(err)
                    events = aurp_global.event;
                    aurp_global.event = 0;
                  }     
                    events = aurp_global.event;
                    aurp_global.event = 0;
                  }     
-               ATENABLE(s, aurp_global.glock);  
 
                /*
                 * Shut down if we have the AE_SHUTDOWN event or if we got
 
                /*
                 * Shut down if we have the AE_SHUTDOWN event or if we got
@@ -288,9 +287,7 @@ AURPgetmsg(err)
                                 * which will wake us from the sleep at
                                 * the top of the outer loop.
                                 */
                                 * which will wake us from the sleep at
                                 * the top of the outer loop.
                                 */
-                               ATDISABLE(s, aurp_global.glock);
                                aurp_global.event &= ~AE_UDPIP;
                                aurp_global.event &= ~AE_UDPIP;
-                               ATENABLE(s, aurp_global.glock);
                                dPrintf(D_M_AURP, D_L_WARNING, ("AURPgetmsg: spurious soreceive, err==%d, p_mbuf==0x%x\n", *err, (unsigned int) p_mbuf));
                          break;
                }
                                dPrintf(D_M_AURP, D_L_WARNING, ("AURPgetmsg: spurious soreceive, err==%d, p_mbuf==0x%x\n", *err, (unsigned int) p_mbuf));
                          break;
                }
@@ -310,9 +307,7 @@ void aurp_wakeup(__unused struct socket *so, register caddr_t p, __unused int st
        register int bit;
 
        bit = (int) p;
        register int bit;
 
        bit = (int) p;
-       ATDISABLE(s, aurp_global.glock);
        aurp_global.event |= bit;
        aurp_global.event |= bit;
-       ATENABLE(s, aurp_global.glock);
 
        dPrintf(D_M_AURP, D_L_STATE_CHG,
                ("aurp_wakeup: bit 0x%x, aurp_global.event now 0x%x\n",
 
        dPrintf(D_M_AURP, D_L_STATE_CHG,
                ("aurp_wakeup: bit 0x%x, aurp_global.event now 0x%x\n",
@@ -417,7 +412,7 @@ atalk_to_ip(register gbuf_t *m)
        int flags = MSG_DONTWAIT;
        struct sockaddr_in rem_addr;
 
        int flags = MSG_DONTWAIT;
        struct sockaddr_in rem_addr;
 
-       m->m_type = MT_HEADER;
+       m_mchtype(m, MT_HEADER);
        m->m_pkthdr.len = gbuf_msgsize(m);
        m->m_pkthdr.rcvif = 0;
 
        m->m_pkthdr.len = gbuf_msgsize(m);
        m->m_pkthdr.rcvif = 0;
 
@@ -428,14 +423,10 @@ atalk_to_ip(register gbuf_t *m)
        domain = (aurp_domain_t *)gbuf_rptr(m);
        *(long *) &rem_addr.sin_addr = domain->dst_address;
 
        domain = (aurp_domain_t *)gbuf_rptr(m);
        *(long *) &rem_addr.sin_addr = domain->dst_address;
 
-       ATDISABLE(s, aurp_global.glock);
        aurp_global.running++;
        aurp_global.running++;
-       ATENABLE(s, aurp_global.glock);
        if (aurp_global.shutdown) {
                gbuf_freem(m);
        if (aurp_global.shutdown) {
                gbuf_freem(m);
-                       ATDISABLE(s, aurp_global.glock);
                aurp_global.running--;
                aurp_global.running--;
-               ATENABLE(s, aurp_global.glock);
                dPrintf(D_M_AURP, D_L_SHUTDN_INFO,
                        ("atalk_to_ip: detected aurp_global.shutdown state\n"));
                return;
                dPrintf(D_M_AURP, D_L_SHUTDN_INFO,
                        ("atalk_to_ip: detected aurp_global.shutdown state\n"));
                return;
@@ -448,9 +439,8 @@ atalk_to_ip(register gbuf_t *m)
                  error));
        }
 
                  error));
        }
 
-       ATDISABLE(s, aurp_global.glock);
        aurp_global.running--;
        aurp_global.running--;
-       ATENABLE(s, aurp_global.glock);
        return;
 }
 
        return;
 }
 
+#endif  /* AURP_SUPPORT */