summaryrefslogtreecommitdiffstats
path: root/sys/netatalk
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-01-12 15:07:51 +0000
committerrwatson <rwatson@FreeBSD.org>2007-01-12 15:07:51 +0000
commit3f89da14403203e909a8cc15129f552d6d3ef3dc (patch)
tree0c7da38e01fe89ae2fb1dd585f10f4540df68ca0 /sys/netatalk
parent80c43bc68bbcfdb98c932aa8b59f81f7eb3f7e10 (diff)
downloadFreeBSD-src-3f89da14403203e909a8cc15129f552d6d3ef3dc.zip
FreeBSD-src-3f89da14403203e909a8cc15129f552d6d3ef3dc.tar.gz
Clean up DDP layer netatalk code:
- General style(9) cleanup -- white space, braces, line wraps, etc. - Annotate a lack of synchronization the global route cache if the input routine is invoked with parallelism. - Remove unused debugging code.
Diffstat (limited to 'sys/netatalk')
-rw-r--r--sys/netatalk/ddp.h111
-rw-r--r--sys/netatalk/ddp_input.c636
-rw-r--r--sys/netatalk/ddp_output.c296
-rw-r--r--sys/netatalk/ddp_pcb.c531
-rw-r--r--sys/netatalk/ddp_pcb.h4
-rw-r--r--sys/netatalk/ddp_usrreq.c48
-rw-r--r--sys/netatalk/ddp_var.h44
7 files changed, 795 insertions, 875 deletions
diff --git a/sys/netatalk/ddp.h b/sys/netatalk/ddp.h
index 702c3f4..55b55c8 100644
--- a/sys/netatalk/ddp.h
+++ b/sys/netatalk/ddp.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990,1991 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1991 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -22,10 +22,11 @@
*
* $FreeBSD$
*/
+
#ifndef _NETATALK_DDP_H_
-#define _NETATALK_DDP_H_ 1
+#define _NETATALK_DDP_H_
-/*
+/*-
* <-1byte(8bits) ->
* +---------------+
* | 0 | hopc |len|
@@ -53,83 +54,83 @@
* | Src PORT |
* +---------------+
*
- * On Apples, there is also a ddp_type field, after src_port. However,
- * under this unix implementation, user level processes need to be able
- * to set the ddp_type. In later revisions, the ddp_type may only be
- * available in a raw_appletalk interface.
+ * On Apples, there is also a ddp_type field, after src_port. However, under
+ * this unix implementation, user level processes need to be able to set the
+ * ddp_type. In later revisions, the ddp_type may only be available in a
+ * raw_appletalk interface.
*/
struct elaphdr {
- u_char el_dnode;
- u_char el_snode;
- u_char el_type;
+ u_char el_dnode;
+ u_char el_snode;
+ u_char el_type;
};
#define SZ_ELAPHDR 3
-#define ELAP_DDPSHORT 0x01
-#define ELAP_DDPEXTEND 0x02
+#define ELAP_DDPSHORT 0x01
+#define ELAP_DDPEXTEND 0x02
/*
* Extended DDP header. Includes sickness for dealing with arbitrary
* bitfields on a little-endian arch.
*/
struct ddpehdr {
- union {
- struct {
+ union {
+ struct {
#if BYTE_ORDER == BIG_ENDIAN
- unsigned dub_pad:2;
- unsigned dub_hops:4;
- unsigned dub_len:10;
- unsigned dub_sum:16;
+ unsigned dub_pad:2;
+ unsigned dub_hops:4;
+ unsigned dub_len:10;
+ unsigned dub_sum:16;
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned dub_sum:16;
- unsigned dub_len:10;
- unsigned dub_hops:4;
- unsigned dub_pad:2;
+ unsigned dub_sum:16;
+ unsigned dub_len:10;
+ unsigned dub_hops:4;
+ unsigned dub_pad:2;
#endif
- } du_bits;
- unsigned du_bytes;
- } deh_u;
-#define deh_pad deh_u.du_bits.dub_pad
-#define deh_hops deh_u.du_bits.dub_hops
-#define deh_len deh_u.du_bits.dub_len
-#define deh_sum deh_u.du_bits.dub_sum
-#define deh_bytes deh_u.du_bytes
- u_short deh_dnet;
- u_short deh_snet;
- u_char deh_dnode;
- u_char deh_snode;
- u_char deh_dport;
- u_char deh_sport;
+ } du_bits;
+ unsigned du_bytes;
+ } deh_u;
+ u_short deh_dnet;
+ u_short deh_snet;
+ u_char deh_dnode;
+ u_char deh_snode;
+ u_char deh_dport;
+ u_char deh_sport;
};
+#define deh_pad deh_u.du_bits.dub_pad
+#define deh_hops deh_u.du_bits.dub_hops
+#define deh_len deh_u.du_bits.dub_len
+#define deh_sum deh_u.du_bits.dub_sum
+#define deh_bytes deh_u.du_bytes
-#define DDP_MAXHOPS 15
+#define DDP_MAXHOPS 15
struct ddpshdr {
- union {
- struct {
+ union {
+ struct {
#if BYTE_ORDER == BIG_ENDIAN
- unsigned dub_pad:6;
- unsigned dub_len:10;
- unsigned dub_dport:8;
- unsigned dub_sport:8;
+ unsigned dub_pad:6;
+ unsigned dub_len:10;
+ unsigned dub_dport:8;
+ unsigned dub_sport:8;
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned dub_sport:8;
- unsigned dub_dport:8;
- unsigned dub_len:10;
- unsigned dub_pad:6;
+ unsigned dub_sport:8;
+ unsigned dub_dport:8;
+ unsigned dub_len:10;
+ unsigned dub_pad:6;
#endif
- } du_bits;
- unsigned du_bytes;
- } dsh_u;
-#define dsh_pad dsh_u.du_bits.dub_pad
-#define dsh_len dsh_u.du_bits.dub_len
-#define dsh_dport dsh_u.du_bits.dub_dport
-#define dsh_sport dsh_u.du_bits.dub_sport
-#define dsh_bytes dsh_u.du_bytes
+ } du_bits;
+ unsigned du_bytes;
+ } dsh_u;
};
+#define dsh_pad dsh_u.du_bits.dub_pad
+#define dsh_len dsh_u.du_bits.dub_len
+#define dsh_dport dsh_u.du_bits.dub_dport
+#define dsh_sport dsh_u.du_bits.dub_sport
+#define dsh_bytes dsh_u.du_bytes
#endif /* _NETATALK_DDP_H_ */
diff --git a/sys/netatalk/ddp_input.c b/sys/netatalk/ddp_input.c
index c8f9e42..7e15cb1 100644
--- a/sys/netatalk/ddp_input.c
+++ b/sys/netatalk/ddp_input.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1994 Regents of The University of Michigan.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@@ -88,10 +88,9 @@ at2intr(struct mbuf *m)
{
/*
- * Phase 2 packet handling
+ * Phase 2 packet handling .
*/
ddp_input(m, m->m_pkthdr.rcvif, NULL, 2);
- return;
}
void
@@ -102,7 +101,8 @@ at1intr(struct mbuf *m)
/*
* Phase 1 packet handling
*/
- if (m->m_len < SZ_ELAPHDR && ((m = m_pullup(m, SZ_ELAPHDR)) == NULL)) {
+ if (m->m_len < SZ_ELAPHDR && ((m = m_pullup(m, SZ_ELAPHDR)) ==
+ NULL)) {
ddpstat.ddps_tooshort++;
return;
}
@@ -113,392 +113,332 @@ at1intr(struct mbuf *m)
elhp = mtod(m, struct elaphdr *);
m_adj(m, SZ_ELAPHDR);
- if (elhp->el_type == ELAP_DDPEXTEND) {
- ddp_input(m, m->m_pkthdr.rcvif, NULL, 1);
- } else {
+ if (elhp->el_type != ELAP_DDPEXTEND) {
bcopy((caddr_t)elhp, (caddr_t)&elh, SZ_ELAPHDR);
ddp_input(m, m->m_pkthdr.rcvif, &elh, 1);
- }
- return;
+ } else
+ ddp_input(m, m->m_pkthdr.rcvif, NULL, 1);
}
static void
-ddp_input(m, ifp, elh, phase)
- struct mbuf *m;
- struct ifnet *ifp;
- struct elaphdr *elh;
- int phase;
+ddp_input(struct mbuf *m, struct ifnet *ifp, struct elaphdr *elh, int phase)
{
- struct sockaddr_at from, to;
- struct ddpshdr *dsh, ddps;
- struct at_ifaddr *aa;
- struct ddpehdr *deh = NULL, ddpe;
- struct ddpcb *ddp;
- int dlen, mlen;
- u_short cksum = 0;
-
- bzero((caddr_t)&from, sizeof(struct sockaddr_at));
- bzero((caddr_t)&to, sizeof(struct sockaddr_at));
- if (elh != NULL) {
- /*
- * Extract the information in the short header.
- * netowrk information is defaulted to ATADDR_ANYNET
- * and node information comes from the elh info.
- * We must be phase 1.
- */
- ddpstat.ddps_short++;
+ struct sockaddr_at from, to;
+ struct ddpshdr *dsh, ddps;
+ struct at_ifaddr *aa;
+ struct ddpehdr *deh = NULL, ddpe;
+ struct ddpcb *ddp;
+ int dlen, mlen;
+ u_short cksum = 0;
+
+ bzero((caddr_t)&from, sizeof(struct sockaddr_at));
+ bzero((caddr_t)&to, sizeof(struct sockaddr_at));
+ if (elh != NULL) {
+ /*
+ * Extract the information in the short header. Network
+ * information is defaulted to ATADDR_ANYNET and node
+ * information comes from the elh info. We must be phase 1.
+ */
+ ddpstat.ddps_short++;
- if (m->m_len < sizeof(struct ddpshdr) &&
- ((m = m_pullup(m, sizeof(struct ddpshdr))) == NULL)) {
- ddpstat.ddps_tooshort++;
- return;
- }
+ if (m->m_len < sizeof(struct ddpshdr) &&
+ ((m = m_pullup(m, sizeof(struct ddpshdr))) == NULL)) {
+ ddpstat.ddps_tooshort++;
+ return;
+ }
- dsh = mtod(m, struct ddpshdr *);
- bcopy((caddr_t)dsh, (caddr_t)&ddps, sizeof(struct ddpshdr));
- ddps.dsh_bytes = ntohl(ddps.dsh_bytes);
- dlen = ddps.dsh_len;
+ dsh = mtod(m, struct ddpshdr *);
+ bcopy((caddr_t)dsh, (caddr_t)&ddps, sizeof(struct ddpshdr));
+ ddps.dsh_bytes = ntohl(ddps.dsh_bytes);
+ dlen = ddps.dsh_len;
+
+ to.sat_addr.s_net = ATADDR_ANYNET;
+ to.sat_addr.s_node = elh->el_dnode;
+ to.sat_port = ddps.dsh_dport;
+ from.sat_addr.s_net = ATADDR_ANYNET;
+ from.sat_addr.s_node = elh->el_snode;
+ from.sat_port = ddps.dsh_sport;
+
+ /*
+ * Make sure that we point to the phase1 ifaddr info and that
+ * it's valid for this packet.
+ */
+ for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
+ if ((aa->aa_ifp == ifp)
+ && ((aa->aa_flags & AFA_PHASE2) == 0)
+ && ((to.sat_addr.s_node ==
+ AA_SAT(aa)->sat_addr.s_node) ||
+ (to.sat_addr.s_node == ATADDR_BCAST)))
+ break;
+ }
+ /*
+ * maybe we got a broadcast not meant for us.. ditch it.
+ */
+ if (aa == NULL) {
+ m_freem(m);
+ return;
+ }
+ } else {
+ /*
+ * There was no 'elh' passed on. This could still be either
+ * phase1 or phase2. We have a long header, but we may be
+ * running on a phase 1 net. Extract out all the info
+ * regarding this packet's src & dst.
+ */
+ ddpstat.ddps_long++;
- to.sat_addr.s_net = ATADDR_ANYNET;
- to.sat_addr.s_node = elh->el_dnode;
- to.sat_port = ddps.dsh_dport;
- from.sat_addr.s_net = ATADDR_ANYNET;
- from.sat_addr.s_node = elh->el_snode;
- from.sat_port = ddps.dsh_sport;
+ if (m->m_len < sizeof(struct ddpehdr) &&
+ ((m = m_pullup(m, sizeof(struct ddpehdr))) == NULL)) {
+ ddpstat.ddps_tooshort++;
+ return;
+ }
- /*
- * Make sure that we point to the phase1 ifaddr info
- * and that it's valid for this packet.
- */
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if ((aa->aa_ifp == ifp)
- && ((aa->aa_flags & AFA_PHASE2) == 0)
- && ((to.sat_addr.s_node == AA_SAT(aa)->sat_addr.s_node)
- || (to.sat_addr.s_node == ATADDR_BCAST))) {
- break;
- }
- }
- /*
- * maybe we got a broadcast not meant for us.. ditch it.
- */
- if (aa == NULL) {
- m_freem(m);
- return;
+ deh = mtod(m, struct ddpehdr *);
+ bcopy((caddr_t)deh, (caddr_t)&ddpe, sizeof(struct ddpehdr));
+ ddpe.deh_bytes = ntohl(ddpe.deh_bytes);
+ dlen = ddpe.deh_len;
+
+ if ((cksum = ddpe.deh_sum) == 0)
+ ddpstat.ddps_nosum++;
+
+ from.sat_addr.s_net = ddpe.deh_snet;
+ from.sat_addr.s_node = ddpe.deh_snode;
+ from.sat_port = ddpe.deh_sport;
+ to.sat_addr.s_net = ddpe.deh_dnet;
+ to.sat_addr.s_node = ddpe.deh_dnode;
+ to.sat_port = ddpe.deh_dport;
+
+ if (to.sat_addr.s_net == ATADDR_ANYNET) {
+ /*
+ * The TO address doesn't specify a net, so by
+ * definition it's for this net. Try find ifaddr
+ * info with the right phase, the right interface,
+ * and either to our node, a broadcast, or looped
+ * back (though that SHOULD be covered in the other
+ * cases).
+ *
+ * XXX If we have multiple interfaces, then the first
+ * with this node number will match (which may NOT be
+ * what we want, but it's probably safe in 99.999% of
+ * cases.
+ */
+ for (aa = at_ifaddr_list; aa != NULL;
+ aa = aa->aa_next) {
+ if (phase == 1 && (aa->aa_flags &
+ AFA_PHASE2))
+ continue;
+ if (phase == 2 && (aa->aa_flags &
+ AFA_PHASE2) == 0)
+ continue;
+ if ((aa->aa_ifp == ifp) &&
+ ((to.sat_addr.s_node ==
+ AA_SAT(aa)->sat_addr.s_node) ||
+ (to.sat_addr.s_node == ATADDR_BCAST) ||
+ (ifp->if_flags & IFF_LOOPBACK)))
+ break;
+ }
+ } else {
+ /*
+ * A destination network was given. We just try to
+ * find which ifaddr info matches it.
+ */
+ for (aa = at_ifaddr_list; aa != NULL;
+ aa = aa->aa_next) {
+ /*
+ * This is a kludge. Accept packets that are
+ * for any router on a local netrange.
+ */
+ if (to.sat_addr.s_net == aa->aa_firstnet &&
+ to.sat_addr.s_node == 0)
+ break;
+ /*
+ * Don't use ifaddr info for which we are
+ * totally outside the netrange, and it's not
+ * a startup packet. Startup packets are
+ * always implicitly allowed on to the next
+ * test.
+ */
+ if (((ntohs(to.sat_addr.s_net) <
+ ntohs(aa->aa_firstnet)) ||
+ (ntohs(to.sat_addr.s_net) >
+ ntohs(aa->aa_lastnet))) &&
+ ((ntohs(to.sat_addr.s_net) < 0xff00) ||
+ (ntohs(to.sat_addr.s_net) > 0xfffe)))
+ continue;
+
+ /*
+ * Don't record a match either if we just
+ * don't have a match in the node address.
+ * This can have if the interface is in
+ * promiscuous mode for example.
+ */
+ if ((to.sat_addr.s_node !=
+ AA_SAT(aa)->sat_addr.s_node) &&
+ (to.sat_addr.s_node != ATADDR_BCAST))
+ continue;
+ break;
+ }
+ }
}
- } else {
+
/*
- * There was no 'elh' passed on. This could still be
- * either phase1 or phase2.
- * We have a long header, but we may be running on a phase 1 net.
- * Extract out all the info regarding this packet's src & dst.
+ * Adjust the length, removing any padding that may have been added
+ * at a link layer. We do this before we attempt to forward a
+ * packet, possibly on a different media.
*/
- ddpstat.ddps_long++;
-
- if (m->m_len < sizeof(struct ddpehdr) &&
- ((m = m_pullup(m, sizeof(struct ddpehdr))) == NULL)) {
- ddpstat.ddps_tooshort++;
- return;
- }
-
- deh = mtod(m, struct ddpehdr *);
- bcopy((caddr_t)deh, (caddr_t)&ddpe, sizeof(struct ddpehdr));
- ddpe.deh_bytes = ntohl(ddpe.deh_bytes);
- dlen = ddpe.deh_len;
-
- if ((cksum = ddpe.deh_sum) == 0) {
- ddpstat.ddps_nosum++;
+ mlen = m->m_pkthdr.len;
+ if (mlen < dlen) {
+ ddpstat.ddps_toosmall++;
+ m_freem(m);
+ return;
}
+ if (mlen > dlen)
+ m_adj(m, dlen - mlen);
- from.sat_addr.s_net = ddpe.deh_snet;
- from.sat_addr.s_node = ddpe.deh_snode;
- from.sat_port = ddpe.deh_sport;
- to.sat_addr.s_net = ddpe.deh_dnet;
- to.sat_addr.s_node = ddpe.deh_dnode;
- to.sat_port = ddpe.deh_dport;
-
- if (to.sat_addr.s_net == ATADDR_ANYNET) {
- /*
- * The TO address doesn't specify a net,
- * So by definition it's for this net.
- * Try find ifaddr info with the right phase,
- * the right interface, and either to our node, a broadcast,
- * or looped back (though that SHOULD be covered in the other
- * cases).
- *
- * XXX If we have multiple interfaces, then the first with
- * this node number will match (which may NOT be what we want,
- * but it's probably safe in 99.999% of cases.
- */
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if (phase == 1 && (aa->aa_flags & AFA_PHASE2)) {
- continue;
- }
- if (phase == 2 && (aa->aa_flags & AFA_PHASE2) == 0) {
- continue;
+ /*
+ * If it isn't for a net on any of our interfaces, or it IS for a net
+ * on a different interface than it came in on, (and it is not looped
+ * back) then consider if we should forward it. As we are not really
+ * a router this is a bit cheeky, but it may be useful some day.
+ */
+ if ((aa == NULL) || ((to.sat_addr.s_node == ATADDR_BCAST) &&
+ (aa->aa_ifp != ifp) && ((ifp->if_flags & IFF_LOOPBACK) == 0))) {
+ /*
+ * If we've explicitly disabled it, don't route anything.
+ */
+ if (ddp_forward == 0) {
+ m_freem(m);
+ return;
}
- if ((aa->aa_ifp == ifp)
- && ((to.sat_addr.s_node == AA_SAT(aa)->sat_addr.s_node)
- || (to.sat_addr.s_node == ATADDR_BCAST)
- || (ifp->if_flags & IFF_LOOPBACK))) {
- break;
+
+ /*
+ * If the cached forwarding route is still valid, use it.
+ *
+ * XXXRW: Access to the cached route may not be properly
+ * synchronized for parallel input handling.
+ */
+ if (forwro.ro_rt &&
+ (satosat(&forwro.ro_dst)->sat_addr.s_net !=
+ to.sat_addr.s_net ||
+ satosat(&forwro.ro_dst)->sat_addr.s_node !=
+ to.sat_addr.s_node)) {
+ RTFREE(forwro.ro_rt);
+ forwro.ro_rt = NULL;
}
- }
- } else {
- /*
- * A destination network was given. We just try to find
- * which ifaddr info matches it.
- */
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
+
/*
- * This is a kludge. Accept packets that are
- * for any router on a local netrange.
+ * If we don't have a cached one (any more) or it's useless,
+ * then get a new route.
+ *
+ * XXX this could cause a 'route leak'. Check this!
*/
- if (to.sat_addr.s_net == aa->aa_firstnet &&
- to.sat_addr.s_node == 0) {
- break;
+ if (forwro.ro_rt == NULL || forwro.ro_rt->rt_ifp == NULL) {
+ forwro.ro_dst.sa_len = sizeof(struct sockaddr_at);
+ forwro.ro_dst.sa_family = AF_APPLETALK;
+ satosat(&forwro.ro_dst)->sat_addr.s_net =
+ to.sat_addr.s_net;
+ satosat(&forwro.ro_dst)->sat_addr.s_node =
+ to.sat_addr.s_node;
+ rtalloc(&forwro);
}
- /*
- * Don't use ifaddr info for which we are totally outside the
- * netrange, and it's not a startup packet.
- * Startup packets are always implicitly allowed on to
- * the next test.
+
+ /*
+ * If it's not going to get there on this hop, and it's
+ * already done too many hops, then throw it away.
*/
- if (((ntohs(to.sat_addr.s_net) < ntohs(aa->aa_firstnet))
- || (ntohs(to.sat_addr.s_net) > ntohs(aa->aa_lastnet)))
- && ((ntohs(to.sat_addr.s_net) < 0xff00)
- || (ntohs(to.sat_addr.s_net) > 0xfffe))) {
- continue;
+ if ((to.sat_addr.s_net !=
+ satosat(&forwro.ro_dst)->sat_addr.s_net) &&
+ (ddpe.deh_hops == DDP_MAXHOPS)) {
+ m_freem(m);
+ return;
}
/*
- * Don't record a match either if we just don't have a match
- * in the node address. This can have if the interface
- * is in promiscuous mode for example.
+ * A ddp router might use the same interface to forward the
+ * packet, which this would not effect. Don't allow packets
+ * to cross from one interface to another however.
*/
- if ((to.sat_addr.s_node != AA_SAT(aa)->sat_addr.s_node)
- && (to.sat_addr.s_node != ATADDR_BCAST)) {
- continue;
+ if (ddp_firewall && ((forwro.ro_rt == NULL) ||
+ (forwro.ro_rt->rt_ifp != ifp))) {
+ m_freem(m);
+ return;
}
- break;
- }
- }
- }
-
- /*
- * Adjust the length, removing any padding that may have been added
- * at a link layer. We do this before we attempt to forward a packet,
- * possibly on a different media.
- */
- mlen = m->m_pkthdr.len;
- if (mlen < dlen) {
- ddpstat.ddps_toosmall++;
- m_freem(m);
- return;
- }
- if (mlen > dlen) {
- m_adj(m, dlen - mlen);
- }
-
- /*
- * If it aint for a net on any of our interfaces,
- * or it IS for a net on a different interface than it came in on,
- * (and it is not looped back) then consider if we should forward it.
- * As we are not really a router this is a bit cheeky, but it may be
- * useful some day.
- */
- if ((aa == NULL)
- || ((to.sat_addr.s_node == ATADDR_BCAST)
- && (aa->aa_ifp != ifp)
- && ((ifp->if_flags & IFF_LOOPBACK) == 0))) {
- /*
- * If we've explicitly disabled it, don't route anything
- */
- if (ddp_forward == 0) {
- m_freem(m);
- return;
- }
- /*
- * If the cached forwarding route is still valid, use it.
- */
- if (forwro.ro_rt
- && (satosat(&forwro.ro_dst)->sat_addr.s_net != to.sat_addr.s_net
- || satosat(&forwro.ro_dst)->sat_addr.s_node != to.sat_addr.s_node)) {
- RTFREE(forwro.ro_rt);
- forwro.ro_rt = NULL;
+
+ /*
+ * Adjust the header. If it was a short header then it would
+ * have not gotten here, so we can assume there is room to
+ * drop the header in.
+ *
+ * XXX what about promiscuous mode, etc...
+ */
+ ddpe.deh_hops++;
+ ddpe.deh_bytes = htonl(ddpe.deh_bytes);
+ /* XXX deh? */
+ bcopy((caddr_t)&ddpe, (caddr_t)deh, sizeof(u_short));
+ if (ddp_route(m, &forwro))
+ ddpstat.ddps_cantforward++;
+ else
+ ddpstat.ddps_forward++;
+ return;
}
/*
- * If we don't have a cached one (any more) or it's useless,
- * Then get a new route.
- * XXX this could cause a 'route leak'. check this!
+ * It was for us, and we have an ifaddr to use with it.
*/
- if (forwro.ro_rt == NULL || forwro.ro_rt->rt_ifp == NULL) {
- forwro.ro_dst.sa_len = sizeof(struct sockaddr_at);
- forwro.ro_dst.sa_family = AF_APPLETALK;
- satosat(&forwro.ro_dst)->sat_addr.s_net = to.sat_addr.s_net;
- satosat(&forwro.ro_dst)->sat_addr.s_node = to.sat_addr.s_node;
- rtalloc(&forwro);
- }
+ from.sat_len = sizeof(struct sockaddr_at);
+ from.sat_family = AF_APPLETALK;
/*
- * If it's not going to get there on this hop, and it's
- * already done too many hops, then throw it away.
- */
- if ((to.sat_addr.s_net != satosat(&forwro.ro_dst)->sat_addr.s_net)
- && (ddpe.deh_hops == DDP_MAXHOPS)) {
- m_freem(m);
- return;
- }
-
- /*
- * A ddp router might use the same interface
- * to forward the packet, which this would not effect.
- * Don't allow packets to cross from one interface to another however.
+ * We are no longer interested in the link layer so cut it off.
*/
- if (ddp_firewall
- && ((forwro.ro_rt == NULL)
- || (forwro.ro_rt->rt_ifp != ifp))) {
- m_freem(m);
- return;
- }
+ if (elh == NULL) {
+ if (ddp_cksum && cksum && cksum !=
+ at_cksum(m, sizeof(int))) {
+ ddpstat.ddps_badsum++;
+ m_freem(m);
+ return;
+ }
+ m_adj(m, sizeof(struct ddpehdr));
+ } else
+ m_adj(m, sizeof(struct ddpshdr));
- /*
- * Adjust the header.
- * If it was a short header then it would have not gotten here,
- * so we can assume there is room to drop the header in.
- * XXX what about promiscuous mode, etc...
+ /*
+ * Search for ddp protocol control blocks that match these addresses.
*/
- ddpe.deh_hops++;
- ddpe.deh_bytes = htonl(ddpe.deh_bytes);
- bcopy((caddr_t)&ddpe, (caddr_t)deh, sizeof(u_short)); /* XXX deh? */
- if (ddp_route(m, &forwro)) {
- ddpstat.ddps_cantforward++;
- } else {
- ddpstat.ddps_forward++;
- }
- return;
- }
-
- /*
- * It was for us, and we have an ifaddr to use with it.
- */
- from.sat_len = sizeof(struct sockaddr_at);
- from.sat_family = AF_APPLETALK;
-
- /*
- * We are no longer interested in the link layer.
- * so cut it off.
- */
- if (elh != NULL) {
- m_adj(m, sizeof(struct ddpshdr));
- } else {
- if (ddp_cksum && cksum && cksum != at_cksum(m, sizeof(int))) {
- ddpstat.ddps_badsum++;
- m_freem(m);
- return;
- }
- m_adj(m, sizeof(struct ddpehdr));
- }
-
- /*
- * Search for ddp protocol control blocks that match these
- * addresses.
- */
- DDP_LIST_SLOCK();
- if ((ddp = ddp_search(&from, &to, aa)) == NULL) {
- goto out;
- }
+ DDP_LIST_SLOCK();
+ if ((ddp = ddp_search(&from, &to, aa)) == NULL)
+ goto out;
#ifdef MAC
- SOCK_LOCK(ddp->ddp_socket);
- if (mac_check_socket_deliver(ddp->ddp_socket, m) != 0) {
+ SOCK_LOCK(ddp->ddp_socket);
+ if (mac_check_socket_deliver(ddp->ddp_socket, m) != 0) {
+ SOCK_UNLOCK(ddp->ddp_socket);
+ goto out;
+ }
SOCK_UNLOCK(ddp->ddp_socket);
- goto out;
- }
- SOCK_UNLOCK(ddp->ddp_socket);
#endif
- /*
- * If we found one, deliver the packet to the socket
- */
- SOCKBUF_LOCK(&ddp->ddp_socket->so_rcv);
- if (sbappendaddr_locked(&ddp->ddp_socket->so_rcv, (struct sockaddr *)&from,
- m, NULL) == 0) {
- SOCKBUF_UNLOCK(&ddp->ddp_socket->so_rcv);
/*
- * If the socket is full (or similar error) dump the packet.
+ * If we found one, deliver the packet to the socket
*/
- ddpstat.ddps_nosockspace++;
- goto out;
- }
- /*
- * And wake up whatever might be waiting for it
- */
- sorwakeup_locked(ddp->ddp_socket);
- m = NULL;
-out:
- DDP_LIST_SUNLOCK();
- if (m != NULL)
- m_freem(m);
-}
-
-#if 0
-/* As if we haven't got enough of this sort of think floating
-around the kernel :) */
-
-#define BPXLEN 48
-#define BPALEN 16
-#include <ctype.h>
-char hexdig[] = "0123456789ABCDEF";
-
-static void
-bprint(char *data, int len)
-{
- char xout[ BPXLEN ], aout[ BPALEN ];
- int i = 0;
-
- bzero(xout, BPXLEN);
- bzero(aout, BPALEN);
-
- for (;;) {
- if (len < 1) {
- if (i != 0) {
- printf("%s\t%s\n", xout, aout);
- }
- printf("%s\n", "(end)");
- break;
- }
-
- xout[ (i*3) ] = hexdig[ (*data & 0xf0) >> 4 ];
- xout[ (i*3) + 1 ] = hexdig[ *data & 0x0f ];
-
- if ((u_char)*data < 0x7f && (u_char)*data > 0x20) {
- aout[ i ] = *data;
- } else {
- aout[ i ] = '.';
- }
-
- xout[ (i*3) + 2 ] = ' ';
-
- i++;
- len--;
- data++;
-
- if (i > BPALEN - 2) {
- printf("%s\t%s\n", xout, aout);
- bzero(xout, BPXLEN);
- bzero(aout, BPALEN);
- i = 0;
- continue;
+ SOCKBUF_LOCK(&ddp->ddp_socket->so_rcv);
+ if (sbappendaddr_locked(&ddp->ddp_socket->so_rcv,
+ (struct sockaddr *)&from, m, NULL) == 0) {
+ SOCKBUF_UNLOCK(&ddp->ddp_socket->so_rcv);
+ /*
+ * If the socket is full (or similar error) dump the packet.
+ */
+ ddpstat.ddps_nosockspace++;
+ goto out;
}
- }
-}
-static void
-m_printm(struct mbuf *m)
-{
- for (; m; m = m->m_next) {
- bprint(mtod(m, char *), m->m_len);
- }
+ /*
+ * And wake up whatever might be waiting for it
+ */
+ sorwakeup_locked(ddp->ddp_socket);
+ m = NULL;
+out:
+ DDP_LIST_SUNLOCK();
+ if (m != NULL)
+ m_freem(m);
}
-#endif
diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c
index c48f043..c67264e 100644
--- a/sys/netatalk/ddp_output.c
+++ b/sys/netatalk/ddp_output.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990,1991 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1991 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -49,197 +49,187 @@ int ddp_cksum = 1;
int
ddp_output(struct mbuf *m, struct socket *so)
{
- struct ddpehdr *deh;
- struct ddpcb *ddp = sotoddpcb(so);
+ struct ddpehdr *deh;
+ struct ddpcb *ddp = sotoddpcb(so);
#ifdef MAC
- SOCK_LOCK(so);
- mac_create_mbuf_from_socket(so, m);
- SOCK_UNLOCK(so);
+ SOCK_LOCK(so);
+ mac_create_mbuf_from_socket(so, m);
+ SOCK_UNLOCK(so);
#endif
- M_PREPEND(m, sizeof(struct ddpehdr), M_DONTWAIT);
- if (m == NULL)
+ M_PREPEND(m, sizeof(struct ddpehdr), M_DONTWAIT);
+ if (m == NULL)
return (ENOBUFS);
- deh = mtod(m, struct ddpehdr *);
- deh->deh_pad = 0;
- deh->deh_hops = 0;
-
- deh->deh_len = m->m_pkthdr.len;
-
- deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net;
- deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node;
- deh->deh_dport = ddp->ddp_fsat.sat_port;
- deh->deh_snet = ddp->ddp_lsat.sat_addr.s_net;
- deh->deh_snode = ddp->ddp_lsat.sat_addr.s_node;
- deh->deh_sport = ddp->ddp_lsat.sat_port;
-
- /*
- * The checksum calculation is done after all of the other bytes have
- * been filled in.
- */
- if (ddp_cksum) {
- deh->deh_sum = at_cksum(m, sizeof(int));
- } else {
- deh->deh_sum = 0;
- }
- deh->deh_bytes = htonl(deh->deh_bytes);
+ deh = mtod(m, struct ddpehdr *);
+ deh->deh_pad = 0;
+ deh->deh_hops = 0;
+
+ deh->deh_len = m->m_pkthdr.len;
+
+ deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net;
+ deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node;
+ deh->deh_dport = ddp->ddp_fsat.sat_port;
+ deh->deh_snet = ddp->ddp_lsat.sat_addr.s_net;
+ deh->deh_snode = ddp->ddp_lsat.sat_addr.s_node;
+ deh->deh_sport = ddp->ddp_lsat.sat_port;
+
+ /*
+ * The checksum calculation is done after all of the other bytes have
+ * been filled in.
+ */
+ if (ddp_cksum)
+ deh->deh_sum = at_cksum(m, sizeof(int));
+ else
+ deh->deh_sum = 0;
+ deh->deh_bytes = htonl(deh->deh_bytes);
#ifdef NETATALK_DEBUG
- printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n",
+ printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n",
ntohs(deh->deh_snet), deh->deh_snode, deh->deh_sport,
ntohs(deh->deh_dnet), deh->deh_dnode, deh->deh_dport);
#endif
- return (ddp_route(m, &ddp->ddp_route));
+ return (ddp_route(m, &ddp->ddp_route));
}
u_short
at_cksum(struct mbuf *m, int skip)
{
- u_char *data, *end;
- u_long cksum = 0;
-
- for (; m; m = m->m_next) {
- for (data = mtod(m, u_char *), end = data + m->m_len; data < end;
- data++) {
- if (skip) {
- skip--;
- continue;
- }
- cksum = (cksum + *data) << 1;
- if (cksum & 0x00010000) {
- cksum++;
- }
- cksum &= 0x0000ffff;
+ u_char *data, *end;
+ u_long cksum = 0;
+
+ for (; m; m = m->m_next) {
+ for (data = mtod(m, u_char *), end = data + m->m_len;
+ data < end; data++) {
+ if (skip) {
+ skip--;
+ continue;
+ }
+ cksum = (cksum + *data) << 1;
+ if (cksum & 0x00010000)
+ cksum++;
+ cksum &= 0x0000ffff;
+ }
}
- }
- if (cksum == 0) {
- cksum = 0x0000ffff;
- }
- return ((u_short)cksum);
+ if (cksum == 0)
+ cksum = 0x0000ffff;
+ return ((u_short)cksum);
}
int
ddp_route(struct mbuf *m, struct route *ro)
{
- struct sockaddr_at gate;
- struct elaphdr *elh;
- struct mbuf *m0;
- struct at_ifaddr *aa = NULL;
- struct ifnet *ifp = NULL;
- u_short net;
+ struct sockaddr_at gate;
+ struct elaphdr *elh;
+ struct mbuf *m0;
+ struct at_ifaddr *aa = NULL;
+ struct ifnet *ifp = NULL;
+ u_short net;
#if 0
- /* Check for net zero, node zero ("myself") */
- if (satosat(&ro->ro_dst)->sat_addr.s_net == ATADDR_ANYNET
- && satosat(&ro->ro_dst)->sat_addr.s_node == ATADDR_ANYNODE) {
- /* Find the loopback interface */
- }
+ /* Check for net zero, node zero ("myself") */
+ if (satosat(&ro->ro_dst)->sat_addr.s_net == ATADDR_ANYNET
+ && satosat(&ro->ro_dst)->sat_addr.s_node == ATADDR_ANYNODE) {
+ /* Find the loopback interface */
+ }
#endif
- /*
- * if we have a route, find the ifa that refers to this route.
- * I.e The ifa used to get to the gateway.
- */
- if ((ro->ro_rt == NULL)
- || (ro->ro_rt->rt_ifa == NULL)
- || ((ifp = ro->ro_rt->rt_ifa->ifa_ifp) == NULL)) {
- rtalloc(ro);
- }
- if ((ro->ro_rt != NULL)
- && (ro->ro_rt->rt_ifa)
- && (ifp = ro->ro_rt->rt_ifa->ifa_ifp)) {
- net = ntohs(satosat(ro->ro_rt->rt_gateway)->sat_addr.s_net);
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if (((net == 0) || (aa->aa_ifp == ifp)) &&
- net >= ntohs(aa->aa_firstnet) &&
- net <= ntohs(aa->aa_lastnet)) {
- break;
- }
- }
- } else {
- m_freem(m);
+ /*
+ * If we have a route, find the ifa that refers to this route. I.e
+ * the ifa used to get to the gateway.
+ */
+ if ((ro->ro_rt == NULL) || (ro->ro_rt->rt_ifa == NULL) ||
+ ((ifp = ro->ro_rt->rt_ifa->ifa_ifp) == NULL))
+ rtalloc(ro);
+ if ((ro->ro_rt != NULL) && (ro->ro_rt->rt_ifa) &&
+ (ifp = ro->ro_rt->rt_ifa->ifa_ifp)) {
+ net = ntohs(satosat(ro->ro_rt->rt_gateway)->sat_addr.s_net);
+ for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
+ if (((net == 0) || (aa->aa_ifp == ifp)) &&
+ net >= ntohs(aa->aa_firstnet) &&
+ net <= ntohs(aa->aa_lastnet))
+ break;
+ }
+ } else {
+ m_freem(m);
#ifdef NETATALK_DEBUG
- if (ro->ro_rt == NULL)
- printf ("ddp_route: no ro_rt.\n");
- else if (ro->ro_rt->rt_ifa == NULL)
- printf ("ddp_route: no ro_rt->rt_ifa\n");
- else
- printf ("ddp_route: no ro_rt->rt_ifa->ifa_ifp\n");
+ if (ro->ro_rt == NULL)
+ printf ("ddp_route: no ro_rt.\n");
+ else if (ro->ro_rt->rt_ifa == NULL)
+ printf ("ddp_route: no ro_rt->rt_ifa\n");
+ else
+ printf ("ddp_route: no ro_rt->rt_ifa->ifa_ifp\n");
#endif
- return (ENETUNREACH);
- }
+ return (ENETUNREACH);
+ }
- if (aa == NULL) {
+ if (aa == NULL) {
#ifdef NETATALK_DEBUG
- printf("ddp_route: no atalk address found for %s\n",
- ifp->if_xname);
+ printf("ddp_route: no atalk address found for %s\n",
+ ifp->if_xname);
#endif
- m_freem(m);
- return (ENETUNREACH);
- }
-
- /*
- * if the destination address is on a directly attached node use that,
- * else use the official gateway.
- */
- if (ntohs(satosat(&ro->ro_dst)->sat_addr.s_net) >=
+ m_freem(m);
+ return (ENETUNREACH);
+ }
+
+ /*
+ * If the destination address is on a directly attached node use
+ * that, else use the official gateway.
+ */
+ if (ntohs(satosat(&ro->ro_dst)->sat_addr.s_net) >=
ntohs(aa->aa_firstnet) &&
ntohs(satosat(&ro->ro_dst)->sat_addr.s_net) <=
- ntohs(aa->aa_lastnet)) {
- gate = *satosat(&ro->ro_dst);
- } else {
- gate = *satosat(ro->ro_rt->rt_gateway);
- }
-
- /*
- * There are several places in the kernel where data is added to
- * an mbuf without ensuring that the mbuf pointer is aligned.
- * This is bad for transition routing, since phase 1 and phase 2
- * packets end up poorly aligned due to the three byte elap header.
- */
- if (!(aa->aa_flags & AFA_PHASE2)) {
- MGET(m0, M_DONTWAIT, MT_DATA);
- if (m0 == NULL) {
- m_freem(m);
- printf("ddp_route: no buffers\n");
- return (ENOBUFS);
- }
+ ntohs(aa->aa_lastnet))
+ gate = *satosat(&ro->ro_dst);
+ else
+ gate = *satosat(ro->ro_rt->rt_gateway);
+
+ /*
+ * There are several places in the kernel where data is added to an
+ * mbuf without ensuring that the mbuf pointer is aligned. This is
+ * bad for transition routing, since phase 1 and phase 2 packets end
+ * up poorly aligned due to the three byte elap header.
+ */
+ if (!(aa->aa_flags & AFA_PHASE2)) {
+ MGET(m0, M_DONTWAIT, MT_DATA);
+ if (m0 == NULL) {
+ m_freem(m);
+ printf("ddp_route: no buffers\n");
+ return (ENOBUFS);
+ }
#ifdef MAC
- mac_copy_mbuf(m, m0);
+ mac_copy_mbuf(m, m0);
#endif
- m0->m_next = m;
- /* XXX perhaps we ought to align the header? */
- m0->m_len = SZ_ELAPHDR;
- m = m0;
-
- elh = mtod(m, struct elaphdr *);
- elh->el_snode = satosat(&aa->aa_addr)->sat_addr.s_node;
- elh->el_type = ELAP_DDPEXTEND;
- elh->el_dnode = gate.sat_addr.s_node;
- }
- ro->ro_rt->rt_use++;
+ m0->m_next = m;
+ /* XXX perhaps we ought to align the header? */
+ m0->m_len = SZ_ELAPHDR;
+ m = m0;
+
+ elh = mtod(m, struct elaphdr *);
+ elh->el_snode = satosat(&aa->aa_addr)->sat_addr.s_node;
+ elh->el_type = ELAP_DDPEXTEND;
+ elh->el_dnode = gate.sat_addr.s_node;
+ }
+ ro->ro_rt->rt_use++;
#ifdef NETATALK_DEBUG
- printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s)\n",
- ntohs(satosat(&aa->aa_addr)->sat_addr.s_net),
- satosat(&aa->aa_addr)->sat_addr.s_node,
- ntohs(satosat(&ro->ro_dst)->sat_addr.s_net),
- satosat(&ro->ro_dst)->sat_addr.s_node,
- ntohs(gate.sat_addr.s_net),
- gate.sat_addr.s_node,
- ifp->if_xname);
+ printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s)\n",
+ ntohs(satosat(&aa->aa_addr)->sat_addr.s_net),
+ satosat(&aa->aa_addr)->sat_addr.s_node,
+ ntohs(satosat(&ro->ro_dst)->sat_addr.s_net),
+ satosat(&ro->ro_dst)->sat_addr.s_node,
+ ntohs(gate.sat_addr.s_net), gate.sat_addr.s_node, ifp->if_xname);
#endif
- /* short-circuit the output if we're sending this to ourself */
- if ((satosat(&aa->aa_addr)->sat_addr.s_net == satosat(&ro->ro_dst)->sat_addr.s_net) &&
- (satosat(&aa->aa_addr)->sat_addr.s_node == satosat(&ro->ro_dst)->sat_addr.s_node))
- {
- return (if_simloop(ifp, m, gate.sat_family, 0));
- }
+ /* Short-circuit the output if we're sending this to ourself. */
+ if ((satosat(&aa->aa_addr)->sat_addr.s_net ==
+ satosat(&ro->ro_dst)->sat_addr.s_net) &&
+ (satosat(&aa->aa_addr)->sat_addr.s_node ==
+ satosat(&ro->ro_dst)->sat_addr.s_node))
+ return (if_simloop(ifp, m, gate.sat_family, 0));
- return ((*ifp->if_output)(ifp,
- m, (struct sockaddr *)&gate, NULL)); /* XXX */
+ /* XXX */
+ return ((*ifp->if_output)(ifp, m, (struct sockaddr *)&gate, NULL));
}
diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c
index d9202dc..068d427 100644
--- a/sys/netatalk/ddp_pcb.c
+++ b/sys/netatalk/ddp_pcb.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1994 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -68,232 +68,225 @@
#include <netatalk/at_extern.h>
struct mtx ddp_list_mtx;
-static struct ddpcb *ddp_ports[ ATPORT_LAST ];
+static struct ddpcb *ddp_ports[ATPORT_LAST];
struct ddpcb *ddpcb_list = NULL;
void
at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr)
{
- /*
- * Prevent modification of ddp during copy of addr.
- */
- DDP_LOCK_ASSERT(ddp);
- *addr = sodupsockaddr((struct sockaddr *)&ddp->ddp_lsat, M_NOWAIT);
+ /*
+ * Prevent modification of ddp during copy of addr.
+ */
+ DDP_LOCK_ASSERT(ddp);
+ *addr = sodupsockaddr((struct sockaddr *)&ddp->ddp_lsat, M_NOWAIT);
}
int
at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td)
{
- struct sockaddr_at lsat, *sat;
- struct at_ifaddr *aa;
- struct ddpcb *ddpp;
-
- /*
- * We read and write both the ddp passed in, and also ddp_ports.
- */
- DDP_LIST_XLOCK_ASSERT();
- DDP_LOCK_ASSERT(ddp);
-
- if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT) { /* shouldn't be bound */
- return (EINVAL);
- }
-
- if (addr != NULL) { /* validate passed address */
- sat = (struct sockaddr_at *)addr;
- if (sat->sat_family != AF_APPLETALK) {
- return (EAFNOSUPPORT);
- }
+ struct sockaddr_at lsat, *sat;
+ struct at_ifaddr *aa;
+ struct ddpcb *ddpp;
- if (sat->sat_addr.s_node != ATADDR_ANYNODE ||
- sat->sat_addr.s_net != ATADDR_ANYNET) {
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if ((sat->sat_addr.s_net == AA_SAT(aa)->sat_addr.s_net) &&
- (sat->sat_addr.s_node == AA_SAT(aa)->sat_addr.s_node)) {
- break;
- }
- }
- if (!aa) {
- return (EADDRNOTAVAIL);
- }
- }
+ /*
+ * We read and write both the ddp passed in, and also ddp_ports.
+ */
+ DDP_LIST_XLOCK_ASSERT();
+ DDP_LOCK_ASSERT(ddp);
- if (sat->sat_port != ATADDR_ANYPORT) {
- if (sat->sat_port < ATPORT_FIRST ||
- sat->sat_port >= ATPORT_LAST) {
+ /*
+ * Shouldn't be bound.
+ */
+ if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT)
return (EINVAL);
- }
- if (sat->sat_port < ATPORT_RESERVED &&
- priv_check(td, PRIV_NETATALK_RESERVEDPORT)) {
- return (EACCES);
- }
+
+ /*
+ * Validate passed address.
+ */
+ if (addr != NULL) {
+ sat = (struct sockaddr_at *)addr;
+ if (sat->sat_family != AF_APPLETALK)
+ return (EAFNOSUPPORT);
+
+ if (sat->sat_addr.s_node != ATADDR_ANYNODE ||
+ sat->sat_addr.s_net != ATADDR_ANYNET) {
+ for (aa = at_ifaddr_list; aa != NULL;
+ aa = aa->aa_next) {
+ if ((sat->sat_addr.s_net ==
+ AA_SAT(aa)->sat_addr.s_net) &&
+ (sat->sat_addr.s_node ==
+ AA_SAT(aa)->sat_addr.s_node))
+ break;
+ }
+ if (aa == NULL)
+ return (EADDRNOTAVAIL);
+ }
+
+ if (sat->sat_port != ATADDR_ANYPORT) {
+ if (sat->sat_port < ATPORT_FIRST ||
+ sat->sat_port >= ATPORT_LAST)
+ return (EINVAL);
+ if (sat->sat_port < ATPORT_RESERVED &&
+ priv_check(td, PRIV_NETATALK_RESERVEDPORT))
+ return (EACCES);
+ }
+ } else {
+ bzero((caddr_t)&lsat, sizeof(struct sockaddr_at));
+ lsat.sat_len = sizeof(struct sockaddr_at);
+ lsat.sat_addr.s_node = ATADDR_ANYNODE;
+ lsat.sat_addr.s_net = ATADDR_ANYNET;
+ lsat.sat_family = AF_APPLETALK;
+ sat = &lsat;
}
- } else {
- bzero((caddr_t)&lsat, sizeof(struct sockaddr_at));
- lsat.sat_len = sizeof(struct sockaddr_at);
- lsat.sat_addr.s_node = ATADDR_ANYNODE;
- lsat.sat_addr.s_net = ATADDR_ANYNET;
- lsat.sat_family = AF_APPLETALK;
- sat = &lsat;
- }
-
- if (sat->sat_addr.s_node == ATADDR_ANYNODE &&
+
+ if (sat->sat_addr.s_node == ATADDR_ANYNODE &&
sat->sat_addr.s_net == ATADDR_ANYNET) {
- if (at_ifaddr_list == NULL) {
- return (EADDRNOTAVAIL);
- }
- sat->sat_addr = AA_SAT(at_ifaddr_list)->sat_addr;
- }
- ddp->ddp_lsat = *sat;
-
- /*
- * Choose port.
- */
- if (sat->sat_port == ATADDR_ANYPORT) {
- for (sat->sat_port = ATPORT_RESERVED;
- sat->sat_port < ATPORT_LAST; sat->sat_port++) {
- if (ddp_ports[ sat->sat_port - 1 ] == NULL) {
- break;
- }
+ if (at_ifaddr_list == NULL)
+ return (EADDRNOTAVAIL);
+ sat->sat_addr = AA_SAT(at_ifaddr_list)->sat_addr;
}
- if (sat->sat_port == ATPORT_LAST) {
- return (EADDRNOTAVAIL);
- }
- ddp->ddp_lsat.sat_port = sat->sat_port;
- ddp_ports[ sat->sat_port - 1 ] = ddp;
- } else {
- for (ddpp = ddp_ports[ sat->sat_port - 1 ]; ddpp;
- ddpp = ddpp->ddp_pnext) {
- if (ddpp->ddp_lsat.sat_addr.s_net == sat->sat_addr.s_net &&
- ddpp->ddp_lsat.sat_addr.s_node == sat->sat_addr.s_node) {
- break;
- }
- }
- if (ddpp != NULL) {
- return (EADDRINUSE);
- }
- ddp->ddp_pnext = ddp_ports[ sat->sat_port - 1 ];
- ddp_ports[ sat->sat_port - 1 ] = ddp;
- if (ddp->ddp_pnext) {
- ddp->ddp_pnext->ddp_pprev = ddp;
+ ddp->ddp_lsat = *sat;
+
+ /*
+ * Choose port.
+ */
+ if (sat->sat_port == ATADDR_ANYPORT) {
+ for (sat->sat_port = ATPORT_RESERVED;
+ sat->sat_port < ATPORT_LAST; sat->sat_port++) {
+ if (ddp_ports[sat->sat_port - 1] == NULL)
+ break;
+ }
+ if (sat->sat_port == ATPORT_LAST)
+ return (EADDRNOTAVAIL);
+ ddp->ddp_lsat.sat_port = sat->sat_port;
+ ddp_ports[sat->sat_port - 1] = ddp;
+ } else {
+ for (ddpp = ddp_ports[sat->sat_port - 1]; ddpp;
+ ddpp = ddpp->ddp_pnext) {
+ if (ddpp->ddp_lsat.sat_addr.s_net ==
+ sat->sat_addr.s_net &&
+ ddpp->ddp_lsat.sat_addr.s_node ==
+ sat->sat_addr.s_node)
+ break;
+ }
+ if (ddpp != NULL)
+ return (EADDRINUSE);
+ ddp->ddp_pnext = ddp_ports[sat->sat_port - 1];
+ ddp_ports[sat->sat_port - 1] = ddp;
+ if (ddp->ddp_pnext != NULL)
+ ddp->ddp_pnext->ddp_pprev = ddp;
}
- }
- return (0);
+ return (0);
}
int
at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td)
{
- struct sockaddr_at *sat = (struct sockaddr_at *)addr;
- struct route *ro;
- struct at_ifaddr *aa = NULL;
- struct ifnet *ifp;
- u_short hintnet = 0, net;
-
- DDP_LIST_XLOCK_ASSERT();
- DDP_LOCK_ASSERT(ddp);
-
- if (sat->sat_family != AF_APPLETALK) {
- return (EAFNOSUPPORT);
- }
-
- /*
- * Under phase 2, network 0 means "the network". We take "the
- * network" to mean the network the control block is bound to.
- * If the control block is not bound, there is an error.
- */
- if (sat->sat_addr.s_net == ATADDR_ANYNET
- && sat->sat_addr.s_node != ATADDR_ANYNODE) {
- if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) {
- return (EADDRNOTAVAIL);
- }
- hintnet = ddp->ddp_lsat.sat_addr.s_net;
- }
-
- ro = &ddp->ddp_route;
- /*
- * If we've got an old route for this pcb, check that it is valid.
- * If we've changed our address, we may have an old "good looking"
- * route here. Attempt to detect it.
- */
- if (ro->ro_rt) {
- if (hintnet) {
- net = hintnet;
- } else {
- net = sat->sat_addr.s_net;
+ struct sockaddr_at *sat = (struct sockaddr_at *)addr;
+ struct route *ro;
+ struct at_ifaddr *aa = NULL;
+ struct ifnet *ifp;
+ u_short hintnet = 0, net;
+
+ DDP_LIST_XLOCK_ASSERT();
+ DDP_LOCK_ASSERT(ddp);
+
+ if (sat->sat_family != AF_APPLETALK)
+ return (EAFNOSUPPORT);
+
+ /*
+ * Under phase 2, network 0 means "the network". We take "the
+ * network" to mean the network the control block is bound to. If
+ * the control block is not bound, there is an error.
+ */
+ if (sat->sat_addr.s_net == ATADDR_ANYNET &&
+ sat->sat_addr.s_node != ATADDR_ANYNODE) {
+ if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT)
+ return (EADDRNOTAVAIL);
+ hintnet = ddp->ddp_lsat.sat_addr.s_net;
}
- aa = NULL;
- if ((ifp = ro->ro_rt->rt_ifp) != NULL) {
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if (aa->aa_ifp == ifp &&
- ntohs(net) >= ntohs(aa->aa_firstnet) &&
- ntohs(net) <= ntohs(aa->aa_lastnet)) {
- break;
+
+ ro = &ddp->ddp_route;
+ /*
+ * If we've got an old route for this pcb, check that it is valid.
+ * If we've changed our address, we may have an old "good looking"
+ * route here. Attempt to detect it.
+ */
+ if (ro->ro_rt) {
+ if (hintnet)
+ net = hintnet;
+ else
+ net = sat->sat_addr.s_net;
+ aa = NULL;
+ if ((ifp = ro->ro_rt->rt_ifp) != NULL) {
+ for (aa = at_ifaddr_list; aa != NULL;
+ aa = aa->aa_next) {
+ if (aa->aa_ifp == ifp &&
+ ntohs(net) >= ntohs(aa->aa_firstnet) &&
+ ntohs(net) <= ntohs(aa->aa_lastnet))
+ break;
+ }
+ }
+ if (aa == NULL || (satosat(&ro->ro_dst)->sat_addr.s_net !=
+ (hintnet ? hintnet : sat->sat_addr.s_net) ||
+ satosat(&ro->ro_dst)->sat_addr.s_node !=
+ sat->sat_addr.s_node)) {
+ RTFREE(ro->ro_rt);
+ ro->ro_rt = NULL;
}
- }
- }
- if (aa == NULL || (satosat(&ro->ro_dst)->sat_addr.s_net !=
- (hintnet ? hintnet : sat->sat_addr.s_net) ||
- satosat(&ro->ro_dst)->sat_addr.s_node !=
- sat->sat_addr.s_node)) {
- RTFREE(ro->ro_rt);
- ro->ro_rt = NULL;
}
- }
-
- /*
- * If we've got no route for this interface, try to find one.
- */
- if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) {
- ro->ro_dst.sa_len = sizeof(struct sockaddr_at);
- ro->ro_dst.sa_family = AF_APPLETALK;
- if (hintnet) {
- satosat(&ro->ro_dst)->sat_addr.s_net = hintnet;
- } else {
- satosat(&ro->ro_dst)->sat_addr.s_net = sat->sat_addr.s_net;
+
+ /*
+ * If we've got no route for this interface, try to find one.
+ */
+ if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) {
+ ro->ro_dst.sa_len = sizeof(struct sockaddr_at);
+ ro->ro_dst.sa_family = AF_APPLETALK;
+ if (hintnet)
+ satosat(&ro->ro_dst)->sat_addr.s_net = hintnet;
+ else
+ satosat(&ro->ro_dst)->sat_addr.s_net =
+ sat->sat_addr.s_net;
+ satosat(&ro->ro_dst)->sat_addr.s_node = sat->sat_addr.s_node;
+ rtalloc(ro);
}
- satosat(&ro->ro_dst)->sat_addr.s_node = sat->sat_addr.s_node;
- rtalloc(ro);
- }
-
- /*
- * Make sure any route that we have has a valid interface.
- */
- aa = NULL;
- if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp)) {
- for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
- if (aa->aa_ifp == ifp) {
- break;
- }
+
+ /*
+ * Make sure any route that we have has a valid interface.
+ */
+ aa = NULL;
+ if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp)) {
+ for (aa = at_ifaddr_list; aa != NULL; aa = aa->aa_next) {
+ if (aa->aa_ifp == ifp)
+ break;
+ }
}
- }
- if (aa == NULL) {
- return (ENETUNREACH);
- }
-
- ddp->ddp_fsat = *sat;
- if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) {
- return (at_pcbsetaddr(ddp, NULL, td));
- }
- return (0);
+ if (aa == NULL)
+ return (ENETUNREACH);
+
+ ddp->ddp_fsat = *sat;
+ if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT)
+ return (at_pcbsetaddr(ddp, NULL, td));
+ return (0);
}
void
at_pcbdisconnect(struct ddpcb *ddp)
{
- DDP_LOCK_ASSERT(ddp);
+ DDP_LOCK_ASSERT(ddp);
- ddp->ddp_fsat.sat_addr.s_net = ATADDR_ANYNET;
- ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
- ddp->ddp_fsat.sat_port = ATADDR_ANYPORT;
+ ddp->ddp_fsat.sat_addr.s_net = ATADDR_ANYNET;
+ ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
+ ddp->ddp_fsat.sat_port = ATADDR_ANYPORT;
}
int
at_pcballoc(struct socket *so)
{
- struct ddpcb *ddp;
+ struct ddpcb *ddp;
DDP_LIST_XLOCK_ASSERT();
@@ -310,9 +303,8 @@ at_pcballoc(struct socket *so)
ddp->ddp_prev = NULL;
ddp->ddp_pprev = NULL;
ddp->ddp_pnext = NULL;
- if (ddpcb_list != NULL) {
+ if (ddpcb_list != NULL)
ddpcb_list->ddp_prev = ddp;
- }
ddpcb_list = ddp;
return(0);
}
@@ -321,100 +313,95 @@ void
at_pcbdetach(struct socket *so, struct ddpcb *ddp)
{
- /*
- * We modify ddp, ddp_ports, and the global list.
- */
- DDP_LIST_XLOCK_ASSERT();
- DDP_LOCK_ASSERT(ddp);
- KASSERT(so->so_pcb != NULL, ("at_pcbdetach: so_pcb == NULL"));
+ /*
+ * We modify ddp, ddp_ports, and the global list.
+ */
+ DDP_LIST_XLOCK_ASSERT();
+ DDP_LOCK_ASSERT(ddp);
+ KASSERT(so->so_pcb != NULL, ("at_pcbdetach: so_pcb == NULL"));
+
+ so->so_pcb = NULL;
+
+ /* Remove ddp from ddp_ports list. */
+ if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT &&
+ ddp_ports[ddp->ddp_lsat.sat_port - 1] != NULL) {
+ if (ddp->ddp_pprev != NULL)
+ ddp->ddp_pprev->ddp_pnext = ddp->ddp_pnext;
+ else
+ ddp_ports[ddp->ddp_lsat.sat_port - 1] = ddp->ddp_pnext;
+ if (ddp->ddp_pnext != NULL)
+ ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev;
+ }
- so->so_pcb = NULL;
+ if (ddp->ddp_route.ro_rt)
+ RTFREE(ddp->ddp_route.ro_rt);
- /* remove ddp from ddp_ports list */
- if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT &&
- ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] != NULL) {
- if (ddp->ddp_pprev != NULL) {
- ddp->ddp_pprev->ddp_pnext = ddp->ddp_pnext;
- } else {
- ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] = ddp->ddp_pnext;
- }
- if (ddp->ddp_pnext != NULL) {
- ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev;
- }
- }
-
- if (ddp->ddp_route.ro_rt) {
- RTFREE(ddp->ddp_route.ro_rt);
- }
-
- if (ddp->ddp_prev) {
- ddp->ddp_prev->ddp_next = ddp->ddp_next;
- } else {
- ddpcb_list = ddp->ddp_next;
- }
- if (ddp->ddp_next) {
- ddp->ddp_next->ddp_prev = ddp->ddp_prev;
- }
- DDP_UNLOCK(ddp);
- DDP_LOCK_DESTROY(ddp);
- FREE(ddp, M_PCB);
+ if (ddp->ddp_prev)
+ ddp->ddp_prev->ddp_next = ddp->ddp_next;
+ else
+ ddpcb_list = ddp->ddp_next;
+ if (ddp->ddp_next)
+ ddp->ddp_next->ddp_prev = ddp->ddp_prev;
+ DDP_UNLOCK(ddp);
+ DDP_LOCK_DESTROY(ddp);
+ FREE(ddp, M_PCB);
}
/*
- * For the moment, this just find the pcb with the correct local address.
- * In the future, this will actually do some real searching, so we can use
- * the sender's address to do de-multiplexing on a single port to many
- * sockets (pcbs).
+ * For the moment, this just find the pcb with the correct local address. In
+ * the future, this will actually do some real searching, so we can use the
+ * sender's address to do de-multiplexing on a single port to many sockets
+ * (pcbs).
*/
struct ddpcb *
ddp_search(struct sockaddr_at *from, struct sockaddr_at *to,
- struct at_ifaddr *aa)
+ struct at_ifaddr *aa)
{
- struct ddpcb *ddp;
-
- DDP_LIST_SLOCK_ASSERT();
-
- /*
- * Check for bad ports.
- */
- if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST) {
- return (NULL);
- }
-
- /*
- * Make sure the local address matches the sent address. What about
- * the interface?
- */
- for (ddp = ddp_ports[ to->sat_port - 1 ]; ddp; ddp = ddp->ddp_pnext) {
- DDP_LOCK(ddp);
- /* XXX should we handle 0.YY? */
-
- /* XXXX.YY to socket on destination interface */
- if (to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net &&
- to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node) {
- DDP_UNLOCK(ddp);
- break;
- }
+ struct ddpcb *ddp;
+
+ DDP_LIST_SLOCK_ASSERT();
+
+ /*
+ * Check for bad ports.
+ */
+ if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST)
+ return (NULL);
+
+ /*
+ * Make sure the local address matches the sent address. What about
+ * the interface?
+ */
+ for (ddp = ddp_ports[to->sat_port - 1]; ddp; ddp = ddp->ddp_pnext) {
+ DDP_LOCK(ddp);
+ /* XXX should we handle 0.YY? */
+ /* XXXX.YY to socket on destination interface */
+ if (to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net &&
+ to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node) {
+ DDP_UNLOCK(ddp);
+ break;
+ }
- /* 0.255 to socket on receiving interface */
- if (to->sat_addr.s_node == ATADDR_BCAST && (to->sat_addr.s_net == 0 ||
- to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net) &&
- ddp->ddp_lsat.sat_addr.s_net == AA_SAT(aa)->sat_addr.s_net) {
- DDP_UNLOCK(ddp);
- break;
- }
+ /* 0.255 to socket on receiving interface */
+ if (to->sat_addr.s_node == ATADDR_BCAST &&
+ (to->sat_addr.s_net == 0 ||
+ to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net) &&
+ ddp->ddp_lsat.sat_addr.s_net ==
+ AA_SAT(aa)->sat_addr.s_net) {
+ DDP_UNLOCK(ddp);
+ break;
+ }
- /* XXXX.0 to socket on destination interface */
- if (to->sat_addr.s_net == aa->aa_firstnet &&
- to->sat_addr.s_node == 0 &&
- ntohs(ddp->ddp_lsat.sat_addr.s_net) >=
- ntohs(aa->aa_firstnet) &&
- ntohs(ddp->ddp_lsat.sat_addr.s_net) <=
- ntohs(aa->aa_lastnet)) {
- DDP_UNLOCK(ddp);
- break;
+ /* XXXX.0 to socket on destination interface */
+ if (to->sat_addr.s_net == aa->aa_firstnet &&
+ to->sat_addr.s_node == 0 &&
+ ntohs(ddp->ddp_lsat.sat_addr.s_net) >=
+ ntohs(aa->aa_firstnet) &&
+ ntohs(ddp->ddp_lsat.sat_addr.s_net) <=
+ ntohs(aa->aa_lastnet)) {
+ DDP_UNLOCK(ddp);
+ break;
+ }
+ DDP_UNLOCK(ddp);
}
- DDP_UNLOCK(ddp);
- }
- return (ddp);
+ return (ddp);
}
diff --git a/sys/netatalk/ddp_pcb.h b/sys/netatalk/ddp_pcb.h
index fc6c848..d71836f 100644
--- a/sys/netatalk/ddp_pcb.h
+++ b/sys/netatalk/ddp_pcb.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1994 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -81,4 +81,4 @@ void at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr);
#define DDP_LIST_SUNLOCK() mtx_unlock(&ddp_list_mtx)
#define DDP_LIST_SLOCK_ASSERT() mtx_assert(&ddp_list_mtx, MA_OWNED)
-#endif
+#endif /* !_NETATALK_DDP_PCB_H_ */
diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c
index 2d5d55f..d2af633 100644
--- a/sys/netatalk/ddp_usrreq.c
+++ b/sys/netatalk/ddp_usrreq.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1994 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -75,8 +75,8 @@ static struct ifqueue atintrq1, atintrq2, aarpintrq;
static int
ddp_attach(struct socket *so, int proto, struct thread *td)
{
- struct ddpcb *ddp;
- int error = 0;
+ struct ddpcb *ddp;
+ int error = 0;
ddp = sotoddpcb(so);
KASSERT(ddp == NULL, ("ddp_attach: ddp != NULL"));
@@ -98,7 +98,7 @@ ddp_attach(struct socket *so, int proto, struct thread *td)
static void
ddp_detach(struct socket *so)
{
- struct ddpcb *ddp;
+ struct ddpcb *ddp;
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_detach: ddp == NULL"));
@@ -112,8 +112,8 @@ ddp_detach(struct socket *so)
static int
ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
- struct ddpcb *ddp;
- int error = 0;
+ struct ddpcb *ddp;
+ int error = 0;
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_bind: ddp == NULL"));
@@ -129,8 +129,8 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
static int
ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
{
- struct ddpcb *ddp;
- int error = 0;
+ struct ddpcb *ddp;
+ int error = 0;
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_connect: ddp == NULL"));
@@ -138,32 +138,31 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
DDP_LIST_XLOCK();
DDP_LOCK(ddp);
if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) {
- DDP_UNLOCK(ddp);
- DDP_LIST_XUNLOCK();
- return (EISCONN);
+ DDP_UNLOCK(ddp);
+ DDP_LIST_XUNLOCK();
+ return (EISCONN);
}
error = at_pcbconnect( ddp, nam, td );
DDP_UNLOCK(ddp);
DDP_LIST_XUNLOCK();
if (error == 0)
- soisconnected(so);
+ soisconnected(so);
return (error);
}
static int
ddp_disconnect(struct socket *so)
{
-
- struct ddpcb *ddp;
+ struct ddpcb *ddp;
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_disconnect: ddp == NULL"));
DDP_LOCK(ddp);
if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE) {
- DDP_UNLOCK(ddp);
- return (ENOTCONN);
+ DDP_UNLOCK(ddp);
+ return (ENOTCONN);
}
at_pcbdisconnect(ddp);
@@ -187,10 +186,10 @@ ddp_shutdown(struct socket *so)
static int
ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
- struct mbuf *control, struct thread *td)
+ struct mbuf *control, struct thread *td)
{
- struct ddpcb *ddp;
- int error = 0;
+ struct ddpcb *ddp;
+ int error = 0;
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_send: ddp == NULL"));
@@ -260,6 +259,7 @@ ddp_close(struct socket *so)
void
ddp_init(void)
{
+
atintrq1.ifq_maxlen = IFQ_MAXLEN;
atintrq2.ifq_maxlen = IFQ_MAXLEN;
aarpintrq.ifq_maxlen = IFQ_MAXLEN;
@@ -276,18 +276,18 @@ ddp_init(void)
static void
ddp_clean(void)
{
- struct ddpcb *ddp;
+ struct ddpcp *ddp;
- for (ddp = ddpcb_list; ddp != NULL; ddp = ddp->ddp_next) {
- at_pcbdetach(ddp->ddp_socket, ddp);
- }
- DDP_LIST_LOCK_DESTROY();
+ for (ddp = ddpcb_list; ddp != NULL; ddp = ddp->ddp_next)
+ at_pcbdetach(ddp->ddp_socket, ddp);
+ DDP_LIST_LOCK_DESTROY();
}
#endif
static int
at_setpeeraddr(struct socket *so, struct sockaddr **nam)
{
+
return (EOPNOTSUPP);
}
diff --git a/sys/netatalk/ddp_var.h b/sys/netatalk/ddp_var.h
index 6f6c10a..71bbb5b 100644
--- a/sys/netatalk/ddp_var.h
+++ b/sys/netatalk/ddp_var.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * Copyright (c) 1990, 1994 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
@@ -27,35 +27,37 @@
*/
#ifndef _NETATALK_DDP_VAR_H_
-#define _NETATALK_DDP_VAR_H_ 1
+#define _NETATALK_DDP_VAR_H_
+
struct ddpcb {
- struct sockaddr_at ddp_fsat, ddp_lsat;
- struct route ddp_route;
- struct socket *ddp_socket;
- struct ddpcb *ddp_prev, *ddp_next;
- struct ddpcb *ddp_pprev, *ddp_pnext;
- struct mtx ddp_mtx;
+ struct sockaddr_at ddp_fsat, ddp_lsat;
+ struct route ddp_route;
+ struct socket *ddp_socket;
+ struct ddpcb *ddp_prev, *ddp_next;
+ struct ddpcb *ddp_pprev, *ddp_pnext;
+ struct mtx ddp_mtx;
};
-#define sotoddpcb(so) ((struct ddpcb *)(so)->so_pcb)
+#define sotoddpcb(so) ((struct ddpcb *)(so)->so_pcb)
struct ddpstat {
- long ddps_short; /* short header packets received */
- long ddps_long; /* long header packets received */
- long ddps_nosum; /* no checksum */
- long ddps_badsum; /* bad checksum */
- long ddps_tooshort; /* packet too short */
- long ddps_toosmall; /* not enough data */
- long ddps_forward; /* packets forwarded */
- long ddps_encap; /* packets encapsulated */
- long ddps_cantforward; /* packets rcvd for unreachable dest */
- long ddps_nosockspace; /* no space in sockbuf for packet */
+ long ddps_short; /* short header packets received */
+ long ddps_long; /* long header packets received */
+ long ddps_nosum; /* no checksum */
+ long ddps_badsum; /* bad checksum */
+ long ddps_tooshort; /* packet too short */
+ long ddps_toosmall; /* not enough data */
+ long ddps_forward; /* packets forwarded */
+ long ddps_encap; /* packets encapsulated */
+ long ddps_cantforward; /* packets rcvd for unreachable dest */
+ long ddps_nosockspace; /* no space in sockbuf for packet */
};
#ifdef _KERNEL
-extern int ddp_cksum;
+extern int ddp_cksum;
extern struct ddpcb *ddpcb_list;
-extern struct pr_usrreqs ddp_usrreqs;
+extern struct pr_usrreqs ddp_usrreqs;
extern struct mtx ddp_list_mtx;
#endif
+
#endif /* _NETATALK_DDP_VAR_H_ */
OpenPOWER on IntegriCloud