diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c index 3608b57a4662..fa8252a13516 100644 --- a/sys/netipx/ipx.c +++ b/sys/netipx/ipx.c @@ -1,423 +1,413 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx.c */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include /* * XXXRW: Requires synchronization. */ struct ipx_ifaddr *ipx_ifaddr; static void ipx_ifscrub(struct ifnet *ifp, struct ipx_ifaddr *ia); static int ipx_ifinit(struct ifnet *ifp, struct ipx_ifaddr *ia, struct sockaddr_ipx *sipx, int scrub); /* * Generic internet control operations (ioctl's). */ int -ipx_control(so, cmd, data, ifp, td) - struct socket *so; - u_long cmd; - caddr_t data; - register struct ifnet *ifp; - struct thread *td; +ipx_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, + struct thread *td) { - register struct ifreq *ifr = (struct ifreq *)data; - register struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data; - register struct ipx_ifaddr *ia; + struct ifreq *ifr = (struct ifreq *)data; + struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data; + struct ipx_ifaddr *ia; struct ifaddr *ifa; struct ipx_ifaddr *oia; int dstIsNew, hostIsNew; int error = 0; /* * Find address for this interface, if it exists. */ if (ifp == NULL) return (EADDRNOTAVAIL); for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if (ia->ia_ifp == ifp) break; switch (cmd) { case SIOCGIFADDR: if (ia == NULL) return (EADDRNOTAVAIL); *(struct sockaddr_ipx *)&ifr->ifr_addr = ia->ia_addr; return (0); case SIOCGIFBRDADDR: if (ia == NULL) return (EADDRNOTAVAIL); if ((ifp->if_flags & IFF_BROADCAST) == 0) return (EINVAL); *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_broadaddr; return (0); case SIOCGIFDSTADDR: if (ia == NULL) return (EADDRNOTAVAIL); if ((ifp->if_flags & IFF_POINTOPOINT) == 0) return (EINVAL); *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_dstaddr; return (0); } if (td && (error = suser(td)) != 0) return (error); switch (cmd) { case SIOCAIFADDR: case SIOCDIFADDR: if (ifra->ifra_addr.sipx_family == AF_IPX) for (oia = ia; ia != NULL; ia = ia->ia_next) { if (ia->ia_ifp == ifp && ipx_neteq(ia->ia_addr.sipx_addr, ifra->ifra_addr.sipx_addr)) break; } if (cmd == SIOCDIFADDR && ia == NULL) return (EADDRNOTAVAIL); /* FALLTHROUGH */ case SIOCSIFADDR: case SIOCSIFDSTADDR: if (ia == NULL) { oia = (struct ipx_ifaddr *) malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO); if (oia == NULL) return (ENOBUFS); if ((ia = ipx_ifaddr) != NULL) { for ( ; ia->ia_next != NULL; ia = ia->ia_next) ; ia->ia_next = oia; } else ipx_ifaddr = oia; ia = oia; ifa = (struct ifaddr *)ia; IFA_LOCK_INIT(ifa); ifa->ifa_refcnt = 1; TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); ia->ia_ifp = ifp; ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr; ifa->ifa_netmask = (struct sockaddr *)&ipx_netmask; ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr; if (ifp->if_flags & IFF_BROADCAST) { ia->ia_broadaddr.sipx_family = AF_IPX; ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr); ia->ia_broadaddr.sipx_addr.x_host = ipx_broadhost; } } } switch (cmd) { case SIOCSIFDSTADDR: if ((ifp->if_flags & IFF_POINTOPOINT) == 0) return (EINVAL); if (ia->ia_flags & IFA_ROUTE) { rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); ia->ia_flags &= ~IFA_ROUTE; } if (ifp->if_ioctl) { error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, (void *)ia); if (error) return (error); } *(struct sockaddr *)&ia->ia_dstaddr = ifr->ifr_dstaddr; return (0); case SIOCSIFADDR: return (ipx_ifinit(ifp, ia, (struct sockaddr_ipx *)&ifr->ifr_addr, 1)); case SIOCDIFADDR: ipx_ifscrub(ifp, ia); ifa = (struct ifaddr *)ia; TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link); oia = ia; if (oia == (ia = ipx_ifaddr)) { ipx_ifaddr = ia->ia_next; } else { while (ia->ia_next && (ia->ia_next != oia)) { ia = ia->ia_next; } if (ia->ia_next) ia->ia_next = oia->ia_next; else printf("Didn't unlink ipxifadr from list\n"); } IFAFREE((&oia->ia_ifa)); return (0); case SIOCAIFADDR: dstIsNew = 0; hostIsNew = 1; if (ia->ia_addr.sipx_family == AF_IPX) { if (ifra->ifra_addr.sipx_len == 0) { ifra->ifra_addr = ia->ia_addr; hostIsNew = 0; } else if (ipx_neteq(ifra->ifra_addr.sipx_addr, ia->ia_addr.sipx_addr)) hostIsNew = 0; } if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sipx_family == AF_IPX)) { if (hostIsNew == 0) ipx_ifscrub(ifp, ia); ia->ia_dstaddr = ifra->ifra_dstaddr; dstIsNew = 1; } if (ifra->ifra_addr.sipx_family == AF_IPX && (hostIsNew || dstIsNew)) error = ipx_ifinit(ifp, ia, &ifra->ifra_addr, 0); return (error); default: if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); return ((*ifp->if_ioctl)(ifp, cmd, data)); } } /* * Delete any previous route for an old address. */ static void -ipx_ifscrub(ifp, ia) - register struct ifnet *ifp; - register struct ipx_ifaddr *ia; +ipx_ifscrub(struct ifnet *ifp, struct ipx_ifaddr *ia) { + if (ia->ia_flags & IFA_ROUTE) { if (ifp->if_flags & IFF_POINTOPOINT) { rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); } else rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0); ia->ia_flags &= ~IFA_ROUTE; } } /* * Initialize an interface's internet address * and routing table entry. */ static int -ipx_ifinit(ifp, ia, sipx, scrub) - register struct ifnet *ifp; - register struct ipx_ifaddr *ia; - register struct sockaddr_ipx *sipx; - int scrub; +ipx_ifinit(struct ifnet *ifp, struct ipx_ifaddr *ia, + struct sockaddr_ipx *sipx, int scrub) { struct sockaddr_ipx oldaddr; int s = splimp(), error; /* * Set up new addresses. */ oldaddr = ia->ia_addr; ia->ia_addr = *sipx; /* * The convention we shall adopt for naming is that * a supplied address of zero means that "we don't care". * Use the MAC address of the interface. If it is an * interface without a MAC address, like a serial line, the * address must be supplied. * * Give the interface a chance to initialize * if this is its first address, * and to validate the address if necessary. */ if (ifp->if_ioctl != NULL && (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) { ia->ia_addr = oldaddr; splx(s); return (error); } splx(s); ia->ia_ifa.ifa_metric = ifp->if_metric; /* * Add route for the network. */ if (scrub) { ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr; ipx_ifscrub(ifp, ia); ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; } if (ifp->if_flags & IFF_POINTOPOINT) rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP); else { ia->ia_broadaddr.sipx_addr.x_net = ia->ia_addr.sipx_addr.x_net; rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_UP); } ia->ia_flags |= IFA_ROUTE; return (0); } /* * Return address info for specified internet network. */ struct ipx_ifaddr * -ipx_iaonnetof(dst) - register struct ipx_addr *dst; +ipx_iaonnetof(struct ipx_addr *dst) { - register struct ipx_ifaddr *ia; - register struct ipx_addr *compare; - register struct ifnet *ifp; + struct ipx_ifaddr *ia; + struct ipx_addr *compare; + struct ifnet *ifp; struct ipx_ifaddr *ia_maybe = NULL; union ipx_net net = dst->x_net; for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) { if ((ifp = ia->ia_ifp) != NULL) { if (ifp->if_flags & IFF_POINTOPOINT) { compare = &satoipx_addr(ia->ia_dstaddr); if (ipx_hosteq(*dst, *compare)) return (ia); if (ipx_neteqnn(net, ia->ia_addr.sipx_addr.x_net)) ia_maybe = ia; } else { if (ipx_neteqnn(net, ia->ia_addr.sipx_addr.x_net)) return (ia); } } } return (ia_maybe); } void -ipx_printhost(addr) -register struct ipx_addr *addr; +ipx_printhost(struct ipx_addr *addr) { u_short port; struct ipx_addr work = *addr; - register char *p; register u_char *q; - register char *net = "", *host = ""; + char *p; u_char *q; + char *net = "", *host = ""; char cport[10], chost[15], cnet[15]; port = ntohs(work.x_port); if (ipx_nullnet(work) && ipx_nullhost(work)) { if (port) printf("*.%x", port); else printf("*.*"); return; } if (ipx_wildnet(work)) net = "any"; else if (ipx_nullnet(work)) net = "*"; else { q = work.x_net.c_net; snprintf(cnet, sizeof(cnet), "%x%x%x%x", q[0], q[1], q[2], q[3]); for (p = cnet; *p == '0' && p < cnet + 8; p++) continue; net = p; } if (ipx_wildhost(work)) host = "any"; else if (ipx_nullhost(work)) host = "*"; else { q = work.x_host.c_host; snprintf(chost, sizeof(chost), "%x%x%x%x%x%x", q[0], q[1], q[2], q[3], q[4], q[5]); for (p = chost; *p == '0' && p < chost + 12; p++) continue; host = p; } if (port) { if (strcmp(host, "*") == 0) { host = ""; snprintf(cport, sizeof(cport), "%x", port); } else snprintf(cport, sizeof(cport), ".%x", port); } else *cport = 0; printf("%s.%s%s", net, host, cport); } diff --git a/sys/netipx/ipx.h b/sys/netipx/ipx.h index db1784fa1dcf..c0ef8224e208 100644 --- a/sys/netipx/ipx.h +++ b/sys/netipx/ipx.h @@ -1,194 +1,194 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx.h * * $FreeBSD$ */ #ifndef _NETIPX_IPX_H_ #define _NETIPX_IPX_H_ /* * Constants and Structures */ /* * Protocols */ #define IPXPROTO_UNKWN 0 /* Unknown */ #define IPXPROTO_RI 1 /* RIP Routing Information */ #define IPXPROTO_PXP 4 /* IPX Packet Exchange Protocol */ #define IPXPROTO_SPX 5 /* SPX Sequenced Packet */ #define IPXPROTO_NCP 17 /* NCP NetWare Core */ #define IPXPROTO_NETBIOS 20 /* Propagated Packet */ #define IPXPROTO_RAW 255 /* Placemarker*/ #define IPXPROTO_MAX 256 /* Placemarker*/ /* * Port/Socket numbers: network standard functions */ #define IPXPORT_RI 1 /* NS RIP Routing Information */ #define IPXPORT_ECHO 2 /* NS Echo */ #define IPXPORT_RE 3 /* NS Router Error */ #define IPXPORT_NCP 0x0451 /* NW NCP Core Protocol */ #define IPXPORT_SAP 0x0452 /* NW SAP Service Advertising */ #define IPXPORT_RIP 0x0453 /* NW RIP Routing Information */ #define IPXPORT_NETBIOS 0x0455 /* NW NetBIOS */ #define IPXPORT_DIAGS 0x0456 /* NW Diagnostics */ /* * Ports < IPXPORT_RESERVED are reserved for privileged */ #define IPXPORT_RESERVED 0x4000 /* * Ports > IPXPORT_WELLKNOWN are reserved for privileged * processes (e.g. root). */ #define IPXPORT_WELLKNOWN 0x6000 /* flags passed to ipx_outputfl as last parameter */ #define IPX_FORWARDING 0x1 /* most of ipx header exists */ #define IPX_ROUTETOIF 0x10 /* same as SO_DONTROUTE */ #define IPX_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ #define IPX_MAXHOPS 15 /* flags passed to get/set socket option */ #define SO_HEADERS_ON_INPUT 1 #define SO_HEADERS_ON_OUTPUT 2 #define SO_DEFAULT_HEADERS 3 #define SO_LAST_HEADER 4 #define SO_IPXIP_ROUTE 5 #define SO_SEQNO 6 #define SO_ALL_PACKETS 7 #define SO_MTU 8 #define SO_IPXTUN_ROUTE 9 #define SO_IPX_CHECKSUM 10 /* * IPX addressing */ union ipx_host { u_char c_host[6]; u_short s_host[3]; }; union ipx_net { u_char c_net[4]; u_short s_net[2]; }; union ipx_net_u { union ipx_net net_e; u_long long_e; }; struct ipx_addr { union ipx_net x_net; union ipx_host x_host; u_short x_port; }; /* * Socket address */ struct sockaddr_ipx { u_char sipx_len; u_char sipx_family; struct ipx_addr sipx_addr; char sipx_zero[2]; }; #define sipx_port sipx_addr.x_port /* * Definitions for IPX Internetwork Packet Exchange Protocol */ struct ipx { u_short ipx_sum; /* Checksum */ u_short ipx_len; /* Length, in bytes, including header */ u_char ipx_tc; /* Transport Control (i.e. hop count) */ u_char ipx_pt; /* Packet Type (i.e. level 2 protocol) */ struct ipx_addr ipx_dna; /* Destination Network Address */ struct ipx_addr ipx_sna; /* Source Network Address */ } __packed; #define ipx_neteqnn(a,b) \ (((a).s_net[0] == (b).s_net[0]) && ((a).s_net[1] == (b).s_net[1])) #define ipx_neteq(a,b) ipx_neteqnn((a).x_net, (b).x_net) #define satoipx_addr(sa) (((struct sockaddr_ipx *)&(sa))->sipx_addr) #define ipx_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \ (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2]) #define ipx_hosteq(s,t) (ipx_hosteqnh((s).x_host,(t).x_host)) #define ipx_nullnet(x) (((x).x_net.s_net[0]==0) && ((x).x_net.s_net[1]==0)) #define ipx_nullhost(x) (((x).x_host.s_host[0] == 0) && \ ((x).x_host.s_host[1] == 0) && ((x).x_host.s_host[2] == 0)) #define ipx_wildnet(x) (((x).x_net.s_net[0] == 0xffff) && \ ((x).x_net.s_net[1] == 0xffff)) #define ipx_wildhost(x) (((x).x_host.s_host[0] == 0xffff) && \ ((x).x_host.s_host[1] == 0xffff) && ((x).x_host.s_host[2] == 0xffff)) #include __BEGIN_DECLS -struct ipx_addr ipx_addr(const char *); -char *ipx_ntoa(struct ipx_addr); +struct ipx_addr ipx_addr(const char *); +char *ipx_ntoa(struct ipx_addr); __END_DECLS #endif /* !_NETIPX_IPX_H_ */ diff --git a/sys/netipx/ipx_cksum.c b/sys/netipx/ipx_cksum.c index 3545b524385b..6aa87fbba168 100644 --- a/sys/netipx/ipx_cksum.c +++ b/sys/netipx/ipx_cksum.c @@ -1,139 +1,140 @@ /*- * Copyright (c) 1982, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_cksum.c */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #define SUMADV sum += *w++ u_short -ipx_cksum(struct mbuf *m, int len) { +ipx_cksum(struct mbuf *m, int len) +{ u_int32_t sum = 0; u_char *w; u_char oldtc; int mlen, words; struct ipx *ipx; union { u_char b[2]; u_short w; } buf; ipx = mtod(m, struct ipx*); oldtc = ipx->ipx_tc; ipx->ipx_tc = 0; w = (u_char *)&ipx->ipx_len; len -= 2; mlen = 2; for(;;) { mlen = imin(m->m_len - mlen, len); words = mlen / 2; len -= mlen & ~1; while (words >= 16) { SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; SUMADV; words -= 16; } while (words--) SUMADV; if (len == 0) break; mlen &= 1; if (mlen) { buf.b[0] = *w; if (--len == 0) { buf.b[1] = 0; sum += buf.w; break; } } m = m->m_next; if (m == NULL) break; w = mtod(m, u_char *); if (mlen) { buf.b[1] = *w; sum += buf.w; w++; if (--len == 0) break; } } ipx->ipx_tc = oldtc; sum = (sum & 0xffff) + (sum >> 16); if (sum >= 0x10000) sum++; if (sum) sum = ~sum; return (sum); } diff --git a/sys/netipx/ipx_if.h b/sys/netipx/ipx_if.h index 5958d22ed9f3..07d1c73654a5 100644 --- a/sys/netipx/ipx_if.h +++ b/sys/netipx/ipx_if.h @@ -1,121 +1,121 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_if.h * * $FreeBSD$ */ #ifndef _NETIPX_IPX_IF_H_ #define _NETIPX_IPX_IF_H_ /* * Interface address. One of these structures * is allocated for each interface with an internet address. * The ifaddr structure contains the protocol-independent part * of the structure and is assumed to be first. */ struct ipx_ifaddr { struct ifaddr ia_ifa; /* protocol-independent info */ #define ia_ifp ia_ifa.ifa_ifp #define ia_flags ia_ifa.ifa_flags struct ipx_ifaddr *ia_next; /* next in list of ipx addresses */ struct sockaddr_ipx ia_addr; /* reserve space for my address */ struct sockaddr_ipx ia_dstaddr; /* space for my broadcast address */ #define ia_broadaddr ia_dstaddr struct sockaddr_ipx ia_netmask; /* space for my network mask */ }; struct ipx_aliasreq { char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ struct sockaddr_ipx ifra_addr; struct sockaddr_ipx ifra_broadaddr; #define ifra_dstaddr ifra_broadaddr }; /* * Given a pointer to an ipx_ifaddr (ifaddr), * return a pointer to the addr as a sockadd_ipx. */ #define IA_SIPX(ia) (&(((struct ipx_ifaddr *)(ia))->ia_addr)) /* This is not the right place for this but where is? */ #define ETHERTYPE_IPX_8022 0x00e0 /* Ethernet_802.2 */ #define ETHERTYPE_IPX_8023 0x0000 /* Ethernet_802.3 */ #define ETHERTYPE_IPX_II 0x8137 /* Ethernet_II */ #define ETHERTYPE_IPX_SNAP 0x8137 /* Ethernet_SNAP */ #define ETHERTYPE_IPX 0x8137 /* Only Ethernet_II Available */ #ifdef IPXIP struct ipxip_req { struct sockaddr rq_ipx; /* must be ipx format destination */ struct sockaddr rq_ip; /* must be ip format gateway */ short rq_flags; }; #endif #ifdef _KERNEL extern struct ipx_ifaddr *ipx_ifaddr; -struct ipx_ifaddr *ipx_iaonnetof(struct ipx_addr *dst); +struct ipx_ifaddr *ipx_iaonnetof(struct ipx_addr *dst); #endif #endif /* !_NETIPX_IPX_IF_H_ */ diff --git a/sys/netipx/ipx_input.c b/sys/netipx/ipx_input.c index 166ffdea70e1..e57586cfad92 100644 --- a/sys/netipx/ipx_input.c +++ b/sys/netipx/ipx_input.c @@ -1,506 +1,502 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. * Copyright (c) 2004-2005 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_input.c */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int ipxcksum = 0; SYSCTL_INT(_net_ipx_ipx, OID_AUTO, checksum, CTLFLAG_RW, &ipxcksum, 0, ""); static int ipxprintfs = 0; /* printing forwarding information */ SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxprintfs, CTLFLAG_RW, &ipxprintfs, 0, ""); static int ipxforwarding = 0; SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxforwarding, CTLFLAG_RW, &ipxforwarding, 0, ""); static int ipxnetbios = 0; SYSCTL_INT(_net_ipx, OID_AUTO, ipxnetbios, CTLFLAG_RW, &ipxnetbios, 0, ""); const union ipx_net ipx_zeronet; const union ipx_host ipx_zerohost; const union ipx_net ipx_broadnet = { .s_net[0] = 0xffff, .s_net[1] = 0xffff }; const union ipx_host ipx_broadhost = { .s_host[0] = 0xffff, .s_host[1] = 0xffff, .s_host[2] = 0xffff }; struct ipxstat ipxstat; struct sockaddr_ipx ipx_netmask, ipx_hostmask; /* * IPX protocol control block (pcb) lists. */ struct mtx ipxpcb_list_mtx; struct ipxpcbhead ipxpcb_list; struct ipxpcbhead ipxrawpcb_list; static int ipxqmaxlen = IFQ_MAXLEN; static struct ifqueue ipxintrq; long ipx_pexseq; /* Locked with ipxpcb_list_mtx. */ static int ipx_do_route(struct ipx_addr *src, struct route *ro); static void ipx_undo_route(struct route *ro); static void ipx_forward(struct mbuf *m); static void ipxintr(struct mbuf *m); /* * IPX initialization. */ void -ipx_init() +ipx_init(void) { read_random(&ipx_pexseq, sizeof ipx_pexseq); LIST_INIT(&ipxpcb_list); LIST_INIT(&ipxrawpcb_list); IPX_LIST_LOCK_INIT(); ipx_netmask.sipx_len = 6; ipx_netmask.sipx_addr.x_net = ipx_broadnet; ipx_hostmask.sipx_len = 12; ipx_hostmask.sipx_addr.x_net = ipx_broadnet; ipx_hostmask.sipx_addr.x_host = ipx_broadhost; ipxintrq.ifq_maxlen = ipxqmaxlen; mtx_init(&ipxintrq.ifq_mtx, "ipx_inq", NULL, MTX_DEF); netisr_register(NETISR_IPX, ipxintr, &ipxintrq, NETISR_MPSAFE); } /* * IPX input routine. Pass to next level. */ static void ipxintr(struct mbuf *m) { - register struct ipx *ipx; - register struct ipxpcb *ipxp; + struct ipx *ipx; + struct ipxpcb *ipxp; struct ipx_ifaddr *ia; int len; /* * If no IPX addresses have been set yet but the interfaces * are receiving, can't do anything with incoming packets yet. */ if (ipx_ifaddr == NULL) { m_freem(m); return; } ipxstat.ipxs_total++; if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) && (m = m_pullup(m, sizeof(struct ipx))) == NULL) { ipxstat.ipxs_toosmall++; return; } /* * Give any raw listeners a crack at the packet */ IPX_LIST_LOCK(); LIST_FOREACH(ipxp, &ipxrawpcb_list, ipxp_list) { struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); if (m1 != NULL) { IPX_LOCK(ipxp); ipx_input(m1, ipxp); IPX_UNLOCK(ipxp); } } IPX_LIST_UNLOCK(); ipx = mtod(m, struct ipx *); len = ntohs(ipx->ipx_len); /* * Check that the amount of data in the buffers * is as at least much as the IPX header would have us expect. * Trim mbufs if longer than we expect. * Drop packet if shorter than we expect. */ if (m->m_pkthdr.len < len) { ipxstat.ipxs_tooshort++; m_freem(m); return; } if (m->m_pkthdr.len > len) { if (m->m_len == m->m_pkthdr.len) { m->m_len = len; m->m_pkthdr.len = len; } else m_adj(m, len - m->m_pkthdr.len); } if (ipxcksum && ipx->ipx_sum != 0xffff) { if (ipx->ipx_sum != ipx_cksum(m, len)) { ipxstat.ipxs_badsum++; m_freem(m); return; } } /* * Propagated (Netbios) packets (type 20) has to be handled * different. :-( */ if (ipx->ipx_pt == IPXPROTO_NETBIOS) { if (ipxnetbios) { ipx_output_type20(m); return; } else { m_freem(m); return; } } /* * Is this a directed broadcast? */ if (ipx_hosteqnh(ipx_broadhost,ipx->ipx_dna.x_host)) { if ((!ipx_neteq(ipx->ipx_dna, ipx->ipx_sna)) && (!ipx_neteqnn(ipx->ipx_dna.x_net, ipx_broadnet)) && (!ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet)) && (!ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet)) ) { /* * If it is a broadcast to the net where it was * received from, treat it as ours. */ for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if((ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) && ipx_neteq(ia->ia_addr.sipx_addr, ipx->ipx_dna)) goto ours; /* * Look to see if I need to eat this packet. * Algorithm is to forward all young packets * and prematurely age any packets which will * by physically broadcasted. * Any very old packets eaten without forwarding * would die anyway. * * Suggestion of Bill Nesheim, Cornell U. */ if (ipx->ipx_tc < IPX_MAXHOPS) { ipx_forward(m); return; } } /* * Is this our packet? If not, forward. */ } else { for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if (ipx_hosteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) && (ipx_neteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) || ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet))) break; if (ia == NULL) { ipx_forward(m); return; } } ours: /* * Locate pcb for datagram. */ IPX_LIST_LOCK(); ipxp = ipx_pcblookup(&ipx->ipx_sna, ipx->ipx_dna.x_port, IPX_WILDCARD); /* * Switch out to protocol's input routine. */ if (ipxp != NULL) { ipxstat.ipxs_delivered++; if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS) == 0) switch (ipx->ipx_pt) { case IPXPROTO_SPX: IPX_LOCK(ipxp); /* Will release both locks. */ spx_input(m, ipxp); return; } IPX_LOCK(ipxp); ipx_input(m, ipxp); IPX_UNLOCK(ipxp); } else m_freem(m); IPX_LIST_UNLOCK(); } void ipx_ctlinput(cmd, arg_as_sa, dummy) int cmd; struct sockaddr *arg_as_sa; /* XXX should be swapped with dummy */ void *dummy; { /* Currently, nothing. */ } /* * Forward a packet. If some error occurs drop the packet. IPX don't * have a way to return errors to the sender. */ static struct route ipx_droute; static struct route ipx_sroute; static void -ipx_forward(m) -struct mbuf *m; +ipx_forward(struct mbuf *m) { - register struct ipx *ipx = mtod(m, struct ipx *); - register int error; + struct ipx *ipx = mtod(m, struct ipx *); + int error; int agedelta = 1; int flags = IPX_FORWARDING; int ok_there = 0; int ok_back = 0; if (ipxforwarding == 0) { /* can't tell difference between net and host */ ipxstat.ipxs_cantforward++; m_freem(m); goto cleanup; } ipx->ipx_tc++; if (ipx->ipx_tc > IPX_MAXHOPS) { ipxstat.ipxs_cantforward++; m_freem(m); goto cleanup; } if ((ok_there = ipx_do_route(&ipx->ipx_dna,&ipx_droute)) == 0) { ipxstat.ipxs_noroute++; m_freem(m); goto cleanup; } /* * Here we think about forwarding broadcast packets, * so we try to insure that it doesn't go back out * on the interface it came in on. Also, if we * are going to physically broadcast this, let us * age the packet so we can eat it safely the second time around. */ if (ipx->ipx_dna.x_host.c_host[0] & 0x1) { struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna); struct ifnet *ifp; if (ia != NULL) { /* I'm gonna hafta eat this packet */ agedelta += IPX_MAXHOPS - ipx->ipx_tc; ipx->ipx_tc = IPX_MAXHOPS; } if ((ok_back = ipx_do_route(&ipx->ipx_sna,&ipx_sroute)) == 0) { /* error = ENETUNREACH; He'll never get it! */ ipxstat.ipxs_noroute++; m_freem(m); goto cleanup; } if (ipx_droute.ro_rt && (ifp = ipx_droute.ro_rt->rt_ifp) && ipx_sroute.ro_rt && (ifp != ipx_sroute.ro_rt->rt_ifp)) { flags |= IPX_ALLOWBROADCAST; } else { ipxstat.ipxs_noroute++; m_freem(m); goto cleanup; } } /* * We don't need to recompute checksum because ipx_tc field * is ignored by checksum calculation routine, however * it may be desirable to reset checksum if ipxcksum == 0 */ #if 0 if (!ipxcksum) ipx->ipx_sum = 0xffff; #endif error = ipx_outputfl(m, &ipx_droute, flags); if (error == 0) { ipxstat.ipxs_forward++; if (ipxprintfs) { printf("forward: "); ipx_printhost(&ipx->ipx_sna); printf(" to "); ipx_printhost(&ipx->ipx_dna); printf(" hops %d\n", ipx->ipx_tc); } } cleanup: if (ok_there) ipx_undo_route(&ipx_droute); if (ok_back) ipx_undo_route(&ipx_sroute); } static int -ipx_do_route(src, ro) -struct ipx_addr *src; -struct route *ro; +ipx_do_route(struct ipx_addr *src, struct route *ro) { struct sockaddr_ipx *dst; bzero((caddr_t)ro, sizeof(*ro)); dst = (struct sockaddr_ipx *)&ro->ro_dst; dst->sipx_len = sizeof(*dst); dst->sipx_family = AF_IPX; dst->sipx_addr = *src; dst->sipx_addr.x_port = 0; rtalloc_ign(ro, 0); if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) { return (0); } ro->ro_rt->rt_use++; return (1); } static void -ipx_undo_route(ro) -register struct route *ro; +ipx_undo_route(struct route *ro) { + if (ro->ro_rt != NULL) { RTFREE(ro->ro_rt); } } /* * XXXRW: This code should be run in its own netisr dispatch to avoid a call * back into the socket code from the IPX output path. */ void -ipx_watch_output(m, ifp) -struct mbuf *m; -struct ifnet *ifp; +ipx_watch_output(struct mbuf *m, struct ifnet *ifp) { - register struct ipxpcb *ipxp; - register struct ifaddr *ifa; - register struct ipx_ifaddr *ia; + struct ipxpcb *ipxp; + struct ifaddr *ifa; + struct ipx_ifaddr *ia; + /* * Give any raw listeners a crack at the packet */ IPX_LIST_LOCK(); LIST_FOREACH(ipxp, &ipxrawpcb_list, ipxp_list) { struct mbuf *m0 = m_copy(m, 0, (int)M_COPYALL); if (m0 != NULL) { - register struct ipx *ipx; + struct ipx *ipx; M_PREPEND(m0, sizeof(*ipx), M_DONTWAIT); if (m0 == NULL) continue; ipx = mtod(m0, struct ipx *); ipx->ipx_sna.x_net = ipx_zeronet; for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if (ifp == ia->ia_ifp) break; if (ia == NULL) ipx->ipx_sna.x_host = ipx_zerohost; else ipx->ipx_sna.x_host = ia->ia_addr.sipx_addr.x_host; if (ifp != NULL && (ifp->if_flags & IFF_POINTOPOINT)) TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family == AF_IPX) { ipx->ipx_sna = IA_SIPX(ifa)->sipx_addr; break; } } ipx->ipx_len = ntohl(m0->m_pkthdr.len); IPX_LOCK(ipxp); ipx_input(m0, ipxp); IPX_UNLOCK(ipxp); } } IPX_LIST_UNLOCK(); } diff --git a/sys/netipx/ipx_outputfl.c b/sys/netipx/ipx_outputfl.c index df16bdeb94b7..61d8759ee55c 100644 --- a/sys/netipx/ipx_outputfl.c +++ b/sys/netipx/ipx_outputfl.c @@ -1,285 +1,281 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_outputfl.c */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include static int ipx_copy_output = 0; int -ipx_outputfl(m0, ro, flags) - struct mbuf *m0; - struct route *ro; - int flags; +ipx_outputfl(struct mbuf *m0, struct route *ro, int flags) { - register struct ipx *ipx = mtod(m0, struct ipx *); - register struct ifnet *ifp = NULL; + struct ipx *ipx = mtod(m0, struct ipx *); + struct ifnet *ifp = NULL; int error = 0; struct sockaddr_ipx *dst; struct route ipxroute; /* * Route packet. */ if (ro == NULL) { ro = &ipxroute; bzero((caddr_t)ro, sizeof(*ro)); } dst = (struct sockaddr_ipx *)&ro->ro_dst; if (ro->ro_rt == NULL) { dst->sipx_family = AF_IPX; dst->sipx_len = sizeof(*dst); dst->sipx_addr = ipx->ipx_dna; dst->sipx_addr.x_port = 0; /* * If routing to interface only, * short circuit routing lookup. */ if (flags & IPX_ROUTETOIF) { struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna); if (ia == NULL) { ipxstat.ipxs_noroute++; error = ENETUNREACH; goto bad; } ifp = ia->ia_ifp; goto gotif; } rtalloc_ign(ro, 0); } else if ((ro->ro_rt->rt_flags & RTF_UP) == 0) { /* * The old route has gone away; try for a new one. */ RTFREE(ro->ro_rt); ro->ro_rt = NULL; rtalloc_ign(ro, 0); } if (ro->ro_rt == NULL || (ifp = ro->ro_rt->rt_ifp) == NULL) { ipxstat.ipxs_noroute++; error = ENETUNREACH; goto bad; } ro->ro_rt->rt_use++; if (ro->ro_rt->rt_flags & (RTF_GATEWAY|RTF_HOST)) dst = (struct sockaddr_ipx *)ro->ro_rt->rt_gateway; gotif: /* * Look for multicast addresses and * and verify user is allowed to send * such a packet. */ if (dst->sipx_addr.x_host.c_host[0]&1) { if ((ifp->if_flags & (IFF_BROADCAST | IFF_LOOPBACK)) == 0) { error = EADDRNOTAVAIL; goto bad; } if ((flags & IPX_ALLOWBROADCAST) == 0) { error = EACCES; goto bad; } m0->m_flags |= M_BCAST; } if (htons(ipx->ipx_len) <= ifp->if_mtu) { ipxstat.ipxs_localout++; if (ipx_copy_output) { ipx_watch_output(m0, ifp); } error = (*ifp->if_output)(ifp, m0, (struct sockaddr *)dst, ro->ro_rt); goto done; } else { ipxstat.ipxs_mtutoosmall++; error = EMSGSIZE; } bad: if (ipx_copy_output) { ipx_watch_output(m0, ifp); } m_freem(m0); done: if (ro == &ipxroute && (flags & IPX_ROUTETOIF) == 0 && ro->ro_rt != NULL) { RTFREE(ro->ro_rt); ro->ro_rt = NULL; } return (error); } /* * This will broadcast the type 20 (Netbios) packet to all the interfaces * that have ipx configured and isn't in the list yet. */ int -ipx_output_type20(m) - struct mbuf *m; +ipx_output_type20(struct mbuf *m) { - register struct ipx *ipx; + struct ipx *ipx; union ipx_net *nbnet; struct ipx_ifaddr *ia, *tia = NULL; int error = 0; struct mbuf *m1; int i; struct ifnet *ifp; struct sockaddr_ipx dst; /* * We have to get to the 32 bytes after the ipx header also, so * that we can fill in the network address of the receiving * interface. */ if ((m->m_flags & M_EXT || m->m_len < (sizeof(struct ipx) + 32)) && (m = m_pullup(m, sizeof(struct ipx) + 32)) == NULL) { ipxstat.ipxs_toosmall++; return (0); } ipx = mtod(m, struct ipx *); nbnet = (union ipx_net *)(ipx + 1); if (ipx->ipx_tc >= 8) goto bad; /* * Now see if we have already seen this. */ for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if(ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) { if(tia == NULL) tia = ia; for (i=0;iipx_tc;i++,nbnet++) if(ipx_neteqnn(ia->ia_addr.sipx_addr.x_net, *nbnet)) goto bad; } /* * Don't route the packet if the interface where it come from * does not have an IPX address. */ if(tia == NULL) goto bad; /* * Add our receiving interface to the list. */ nbnet = (union ipx_net *)(ipx + 1); nbnet += ipx->ipx_tc; *nbnet = tia->ia_addr.sipx_addr.x_net; /* * Increment the hop count. */ ipx->ipx_tc++; ipxstat.ipxs_forward++; /* * Send to all directly connected ifaces not in list and * not to the one it came from. */ m->m_flags &= ~M_BCAST; bzero(&dst, sizeof(dst)); dst.sipx_family = AF_IPX; dst.sipx_len = 12; dst.sipx_addr.x_host = ipx_broadhost; for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if(ia->ia_ifa.ifa_ifp != m->m_pkthdr.rcvif) { nbnet = (union ipx_net *)(ipx + 1); for (i=0;iipx_tc;i++,nbnet++) if(ipx_neteqnn(ia->ia_addr.sipx_addr.x_net, *nbnet)) goto skip_this; /* * Insert the net address of the dest net and * calculate the new checksum if needed. */ ifp = ia->ia_ifa.ifa_ifp; dst.sipx_addr.x_net = ia->ia_addr.sipx_addr.x_net; ipx->ipx_dna.x_net = dst.sipx_addr.x_net; if(ipx->ipx_sum != 0xffff) ipx->ipx_sum = ipx_cksum(m, ntohs(ipx->ipx_len)); m1 = m_copym(m, 0, M_COPYALL, M_DONTWAIT); if(m1) { error = (*ifp->if_output)(ifp, m1, (struct sockaddr *)&dst, NULL); /* XXX ipxstat.ipxs_localout++; */ } skip_this: ; } bad: m_freem(m); return (error); } diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c index c6cfd2abd4b8..36c1354e0996 100644 --- a/sys/netipx/ipx_pcb.c +++ b/sys/netipx/ipx_pcb.c @@ -1,413 +1,394 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. * Copyright (c) 2004-2006 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_pcb.c */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include static struct ipx_addr zeroipx_addr; static u_short ipxpcb_lport_cache; int -ipx_pcballoc(so, head, td) - struct socket *so; - struct ipxpcbhead *head; - struct thread *td; +ipx_pcballoc(struct socket *so, struct ipxpcbhead *head, struct thread *td) { - register struct ipxpcb *ipxp; + struct ipxpcb *ipxp; KASSERT(so->so_pcb == NULL, ("ipx_pcballoc: so_pcb != NULL")); IPX_LIST_LOCK_ASSERT(); MALLOC(ipxp, struct ipxpcb *, sizeof *ipxp, M_PCB, M_NOWAIT | M_ZERO); if (ipxp == NULL) return (ENOBUFS); IPX_LOCK_INIT(ipxp); ipxp->ipxp_socket = so; if (ipxcksum) ipxp->ipxp_flags |= IPXP_CHECKSUM; LIST_INSERT_HEAD(head, ipxp, ipxp_list); so->so_pcb = (caddr_t)ipxp; return (0); } int -ipx_pcbbind(ipxp, nam, td) - register struct ipxpcb *ipxp; - struct sockaddr *nam; - struct thread *td; +ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) { - register struct sockaddr_ipx *sipx; + struct sockaddr_ipx *sipx; u_short lport = 0; IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr)) return (EINVAL); if (nam == NULL) goto noname; sipx = (struct sockaddr_ipx *)nam; if (!ipx_nullhost(sipx->sipx_addr)) { int tport = sipx->sipx_port; sipx->sipx_port = 0; /* yech... */ if (ifa_ifwithaddr((struct sockaddr *)sipx) == NULL) return (EADDRNOTAVAIL); sipx->sipx_port = tport; } lport = sipx->sipx_port; if (lport) { u_short aport = ntohs(lport); if (aport < IPXPORT_RESERVED && td != NULL && priv_check(td, PRIV_NETIPX_RESERVEDPORT)) return (EACCES); if (ipx_pcblookup(&zeroipx_addr, lport, 0)) return (EADDRINUSE); } ipxp->ipxp_laddr = sipx->sipx_addr; noname: if (lport == 0) do { ipxpcb_lport_cache++; if ((ipxpcb_lport_cache < IPXPORT_RESERVED) || (ipxpcb_lport_cache >= IPXPORT_WELLKNOWN)) ipxpcb_lport_cache = IPXPORT_RESERVED; lport = htons(ipxpcb_lport_cache); } while (ipx_pcblookup(&zeroipx_addr, lport, 0)); ipxp->ipxp_lport = lport; return (0); } /* * Connect from a socket to a specified address. * Both address and port must be specified in argument sipx. * If don't have a local address for this socket yet, * then pick one. */ int -ipx_pcbconnect(ipxp, nam, td) - struct ipxpcb *ipxp; - struct sockaddr *nam; - struct thread *td; +ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) { struct ipx_ifaddr *ia; - register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; - register struct ipx_addr *dst; - register struct route *ro; + struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; + struct ipx_addr *dst; + struct route *ro; struct ifnet *ifp; IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); ia = NULL; if (sipx->sipx_family != AF_IPX) return (EAFNOSUPPORT); if (sipx->sipx_port == 0 || ipx_nullhost(sipx->sipx_addr)) return (EADDRNOTAVAIL); /* * If we haven't bound which network number to use as ours, * we will use the number of the outgoing interface. * This depends on having done a routing lookup, which * we will probably have to do anyway, so we might * as well do it now. On the other hand if we are * sending to multiple destinations we may have already * done the lookup, so see if we can use the route * from before. In any case, we only * chose a port number once, even if sending to multiple * destinations. */ ro = &ipxp->ipxp_route; dst = &satoipx_addr(ro->ro_dst); if (ipxp->ipxp_socket->so_options & SO_DONTROUTE) goto flush; if (!ipx_neteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) goto flush; if (!ipx_hosteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) { if (ro->ro_rt != NULL && !(ro->ro_rt->rt_flags & RTF_HOST)) { /* can patch route to avoid rtalloc */ *dst = sipx->sipx_addr; } else { flush: if (ro->ro_rt != NULL) RTFREE(ro->ro_rt); ro->ro_rt = NULL; } }/* else cached route is ok; do nothing */ ipxp->ipxp_lastdst = sipx->sipx_addr; if ((ipxp->ipxp_socket->so_options & SO_DONTROUTE) == 0 && /*XXX*/ (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL)) { /* No route yet, so try to acquire one */ ro->ro_dst.sa_family = AF_IPX; ro->ro_dst.sa_len = sizeof(ro->ro_dst); *dst = sipx->sipx_addr; dst->x_port = 0; rtalloc_ign(ro, 0); } if (ipx_neteqnn(ipxp->ipxp_laddr.x_net, ipx_zeronet)) { /* * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. */ /* * If we found a route, use the address * corresponding to the outgoing interface */ if (ro->ro_rt != NULL && (ifp = ro->ro_rt->rt_ifp) != NULL) for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if (ia->ia_ifp == ifp) break; if (ia == NULL) { u_short fport = sipx->sipx_addr.x_port; sipx->sipx_addr.x_port = 0; ia = (struct ipx_ifaddr *) ifa_ifwithdstaddr((struct sockaddr *)sipx); sipx->sipx_addr.x_port = fport; if (ia == NULL) ia = ipx_iaonnetof(&sipx->sipx_addr); if (ia == NULL) ia = ipx_ifaddr; if (ia == NULL) return (EADDRNOTAVAIL); } ipxp->ipxp_laddr.x_net = satoipx_addr(ia->ia_addr).x_net; } if (ipx_nullhost(ipxp->ipxp_laddr)) { /* * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. */ /* * If we found a route, use the address * corresponding to the outgoing interface */ if (ro->ro_rt != NULL && (ifp = ro->ro_rt->rt_ifp) != NULL) for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) if (ia->ia_ifp == ifp) break; if (ia == NULL) { u_short fport = sipx->sipx_addr.x_port; sipx->sipx_addr.x_port = 0; ia = (struct ipx_ifaddr *) ifa_ifwithdstaddr((struct sockaddr *)sipx); sipx->sipx_addr.x_port = fport; if (ia == NULL) ia = ipx_iaonnetof(&sipx->sipx_addr); if (ia == NULL) ia = ipx_ifaddr; if (ia == NULL) return (EADDRNOTAVAIL); } ipxp->ipxp_laddr.x_host = satoipx_addr(ia->ia_addr).x_host; } if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0)) return (EADDRINUSE); if (ipxp->ipxp_lport == 0) ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); /* XXX just leave it zero if we can't find a route */ ipxp->ipxp_faddr = sipx->sipx_addr; /* Includes ipxp->ipxp_fport = sipx->sipx_port; */ return (0); } void -ipx_pcbdisconnect(ipxp) - struct ipxpcb *ipxp; +ipx_pcbdisconnect(struct ipxpcb *ipxp) { IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); ipxp->ipxp_faddr = zeroipx_addr; } void -ipx_pcbdetach(ipxp) - struct ipxpcb *ipxp; +ipx_pcbdetach(struct ipxpcb *ipxp) { struct socket *so = ipxp->ipxp_socket; IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); so->so_pcb = NULL; ipxp->ipxp_socket = NULL; } void -ipx_pcbfree(ipxp) - struct ipxpcb *ipxp; +ipx_pcbfree(struct ipxpcb *ipxp) { KASSERT(ipxp->ipxp_socket == NULL, ("ipx_pcbfree: ipxp_socket != NULL")); IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); if (ipxp->ipxp_route.ro_rt != NULL) RTFREE(ipxp->ipxp_route.ro_rt); LIST_REMOVE(ipxp, ipxp_list); IPX_LOCK_DESTROY(ipxp); FREE(ipxp, M_PCB); } void -ipx_getsockaddr(ipxp, nam) - register struct ipxpcb *ipxp; - struct sockaddr **nam; +ipx_getsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam) { struct sockaddr_ipx *sipx, ssipx; sipx = &ssipx; bzero((caddr_t)sipx, sizeof(*sipx)); sipx->sipx_len = sizeof(*sipx); sipx->sipx_family = AF_IPX; IPX_LOCK(ipxp); sipx->sipx_addr = ipxp->ipxp_laddr; IPX_UNLOCK(ipxp); *nam = sodupsockaddr((struct sockaddr *)sipx, M_WAITOK); } void -ipx_getpeeraddr(ipxp, nam) - register struct ipxpcb *ipxp; - struct sockaddr **nam; +ipx_getpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam) { struct sockaddr_ipx *sipx, ssipx; sipx = &ssipx; bzero(sipx, sizeof(*sipx)); sipx->sipx_len = sizeof(*sipx); sipx->sipx_family = AF_IPX; IPX_LOCK(ipxp); sipx->sipx_addr = ipxp->ipxp_faddr; IPX_UNLOCK(ipxp); *nam = sodupsockaddr((struct sockaddr *)sipx, M_WAITOK); } struct ipxpcb * -ipx_pcblookup(faddr, lport, wildp) - struct ipx_addr *faddr; - u_short lport; - int wildp; +ipx_pcblookup(struct ipx_addr *faddr, u_short lport, int wildp) { - register struct ipxpcb *ipxp, *match = NULL; + struct ipxpcb *ipxp, *match = NULL; int matchwild = 3, wildcard; u_short fport; IPX_LIST_LOCK_ASSERT(); fport = faddr->x_port; LIST_FOREACH(ipxp, &ipxpcb_list, ipxp_list) { if (ipxp->ipxp_lport != lport) continue; wildcard = 0; if (ipx_nullhost(ipxp->ipxp_faddr)) { if (!ipx_nullhost(*faddr)) wildcard++; } else { if (ipx_nullhost(*faddr)) wildcard++; else { if (!ipx_hosteq(ipxp->ipxp_faddr, *faddr)) continue; if (ipxp->ipxp_fport != fport) { if (ipxp->ipxp_fport != 0) continue; else wildcard++; } } } if (wildcard && wildp == 0) continue; if (wildcard < matchwild) { match = ipxp; matchwild = wildcard; if (wildcard == 0) break; } } return (match); } diff --git a/sys/netipx/ipx_pcb.h b/sys/netipx/ipx_pcb.h index 5b5921e97085..4ef60111451f 100644 --- a/sys/netipx/ipx_pcb.h +++ b/sys/netipx/ipx_pcb.h @@ -1,151 +1,150 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. * Copyright (c) 2004-2006 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_pcb.h * * $FreeBSD$ */ #ifndef _NETIPX_IPX_PCB_H_ #define _NETIPX_IPX_PCB_H_ /* * IPX protocol interface control block. */ struct ipxpcb { LIST_ENTRY(ipxpcb) ipxp_list; struct socket *ipxp_socket; /* back pointer to socket */ struct ipx_addr ipxp_faddr; /* destination address */ struct ipx_addr ipxp_laddr; /* socket's address */ caddr_t ipxp_pcb; /* protocol specific stuff */ struct route ipxp_route; /* routing information */ struct ipx_addr ipxp_lastdst; /* validate cached route for dg socks*/ short ipxp_flags; u_char ipxp_dpt; /* default packet type for ipx_output */ u_char ipxp_rpt; /* last received packet type by ipx_input() */ struct mtx ipxp_mtx; }; /* * Additional IPX pcb-related types and variables. */ LIST_HEAD(ipxpcbhead, ipxpcb); extern struct ipxpcbhead ipxpcb_list; extern struct ipxpcbhead ipxrawpcb_list; #ifdef _KERNEL extern struct mtx ipxpcb_list_mtx; #endif /* * IPX/SPX PCB flags. */ #define IPXP_IN_ABORT 0x1 /* Calling abort through socket. */ #define IPXP_RAWIN 0x2 /* Show headers on input. */ #define IPXP_RAWOUT 0x4 /* Show header on output. */ #define IPXP_ALL_PACKETS 0x8 /* Turn off higher proto processing. */ #define IPXP_CHECKSUM 0x10 /* Use checksum on this socket. */ #define IPXP_DROPPED 0x20 /* Connection dropped. */ #define IPXP_SPX 0x40 /* SPX PCB. */ #define IPX_WILDCARD 1 #define ipxp_lport ipxp_laddr.x_port #define ipxp_fport ipxp_faddr.x_port #define sotoipxpcb(so) ((struct ipxpcb *)((so)->so_pcb)) /* * Nominal space allocated to an IPX socket. */ #define IPXSNDQ 16384 #define IPXRCVQ 40960 #ifdef _KERNEL int ipx_pcballoc(struct socket *so, struct ipxpcbhead *head, - struct thread *p); + struct thread *p); int ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam, - struct thread *p); + struct thread *p); int ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam, - struct thread *p); + struct thread *p); void ipx_pcbdetach(struct ipxpcb *ipxp); void ipx_pcbdisconnect(struct ipxpcb *ipxp); void ipx_pcbfree(struct ipxpcb *ipxp); -struct ipxpcb * - ipx_pcblookup(struct ipx_addr *faddr, int lport, int wildp); +struct ipxpcb *ipx_pcblookup(struct ipx_addr *faddr, u_short lport, int wildp); void ipx_getpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam); void ipx_getsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam); #define IPX_LIST_LOCK_INIT() mtx_init(&ipxpcb_list_mtx, "ipx_list_mtx", \ NULL, MTX_DEF | MTX_RECURSE) #define IPX_LIST_LOCK() mtx_lock(&ipxpcb_list_mtx) #define IPX_LIST_UNLOCK() mtx_unlock(&ipxpcb_list_mtx) #define IPX_LIST_LOCK_ASSERT() mtx_assert(&ipxpcb_list_mtx, MA_OWNED) #define IPX_LOCK_INIT(ipx) mtx_init(&(ipx)->ipxp_mtx, "ipx_mtx", NULL, \ MTX_DEF) #define IPX_LOCK_DESTROY(ipx) mtx_destroy(&(ipx)->ipxp_mtx) #define IPX_LOCK(ipx) mtx_lock(&(ipx)->ipxp_mtx) #define IPX_UNLOCK(ipx) mtx_unlock(&(ipx)->ipxp_mtx) #define IPX_LOCK_ASSERT(ipx) mtx_assert(&(ipx)->ipxp_mtx, MA_OWNED) #endif /* _KERNEL */ #endif /* !_NETIPX_IPX_PCB_H_ */ diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c index ad60f4bcde59..fabe2765ea3d 100644 --- a/sys/netipx/ipx_usrreq.c +++ b/sys/netipx/ipx_usrreq.c @@ -1,713 +1,680 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. * Copyright (c) 2004-2006 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_usrreq.c */ #include __FBSDID("$FreeBSD$"); #include "opt_ipx.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * IPX protocol implementation. */ static int ipxsendspace = IPXSNDQ; SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxsendspace, CTLFLAG_RW, &ipxsendspace, 0, ""); static int ipxrecvspace = IPXRCVQ; SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, &ipxrecvspace, 0, ""); static void ipx_usr_abort(struct socket *so); static int ipx_attach(struct socket *so, int proto, struct thread *td); static int ipx_bind(struct socket *so, struct sockaddr *nam, struct thread *td); static int ipx_connect(struct socket *so, struct sockaddr *nam, struct thread *td); static void ipx_detach(struct socket *so); static int ipx_disconnect(struct socket *so); static int ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td); static int ipx_shutdown(struct socket *so); static int ripx_attach(struct socket *so, int proto, struct thread *td); static int ipx_output(struct ipxpcb *ipxp, struct mbuf *m0); static void ipx_usr_close(struct socket *so); struct pr_usrreqs ipx_usrreqs = { .pru_abort = ipx_usr_abort, .pru_attach = ipx_attach, .pru_bind = ipx_bind, .pru_connect = ipx_connect, .pru_control = ipx_control, .pru_detach = ipx_detach, .pru_disconnect = ipx_disconnect, .pru_peeraddr = ipx_peeraddr, .pru_send = ipx_send, .pru_shutdown = ipx_shutdown, .pru_sockaddr = ipx_sockaddr, .pru_close = ipx_usr_close, }; struct pr_usrreqs ripx_usrreqs = { .pru_abort = ipx_usr_abort, .pru_attach = ripx_attach, .pru_bind = ipx_bind, .pru_connect = ipx_connect, .pru_control = ipx_control, .pru_detach = ipx_detach, .pru_disconnect = ipx_disconnect, .pru_peeraddr = ipx_peeraddr, .pru_send = ipx_send, .pru_shutdown = ipx_shutdown, .pru_sockaddr = ipx_sockaddr, .pru_close = ipx_usr_close, }; /* * This may also be called for raw listeners. */ void -ipx_input(m, ipxp) - struct mbuf *m; - register struct ipxpcb *ipxp; +ipx_input(struct mbuf *m, struct ipxpcb *ipxp) { - register struct ipx *ipx = mtod(m, struct ipx *); + struct ipx *ipx = mtod(m, struct ipx *); struct ifnet *ifp = m->m_pkthdr.rcvif; struct sockaddr_ipx ipx_ipx; KASSERT(ipxp != NULL, ("ipx_input: NULL ipxpcb")); IPX_LOCK_ASSERT(ipxp); /* * Construct sockaddr format source address. * Stuff source address and datagram in user buffer. */ ipx_ipx.sipx_len = sizeof(ipx_ipx); ipx_ipx.sipx_family = AF_IPX; ipx_ipx.sipx_addr = ipx->ipx_sna; ipx_ipx.sipx_zero[0] = '\0'; ipx_ipx.sipx_zero[1] = '\0'; if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp != NULL) { - register struct ifaddr *ifa; + struct ifaddr *ifa; for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa != NULL; ifa = TAILQ_NEXT(ifa, ifa_link)) { if (ifa->ifa_addr->sa_family == AF_IPX) { ipx_ipx.sipx_addr.x_net = IA_SIPX(ifa)->sipx_addr.x_net; break; } } } ipxp->ipxp_rpt = ipx->ipx_pt; if ((ipxp->ipxp_flags & IPXP_RAWIN) == 0) { m->m_len -= sizeof(struct ipx); m->m_pkthdr.len -= sizeof(struct ipx); m->m_data += sizeof(struct ipx); } if (sbappendaddr(&ipxp->ipxp_socket->so_rcv, (struct sockaddr *)&ipx_ipx, m, NULL) == 0) m_freem(m); else sorwakeup(ipxp->ipxp_socket); } /* * Drop connection, reporting * the specified error. */ void -ipx_drop(ipxp, errno) - register struct ipxpcb *ipxp; - int errno; +ipx_drop(struct ipxpcb *ipxp, int errno) { struct socket *so = ipxp->ipxp_socket; IPX_LIST_LOCK_ASSERT(); IPX_LOCK_ASSERT(ipxp); /* * someday, in the IPX world * we will generate error protocol packets * announcing that the socket has gone away. * * XXX Probably never. IPX does not have error packets. */ /*if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; tcp_output(tp); }*/ so->so_error = errno; ipx_pcbdisconnect(ipxp); soisdisconnected(so); } static int -ipx_output(ipxp, m0) - struct ipxpcb *ipxp; - struct mbuf *m0; +ipx_output(struct ipxpcb *ipxp, struct mbuf *m0) { - register struct ipx *ipx; - register struct socket *so; - register int len = 0; - register struct route *ro; + struct ipx *ipx; + struct socket *so; + int len = 0; + struct route *ro; struct mbuf *m; struct mbuf *mprev = NULL; IPX_LOCK_ASSERT(ipxp); /* * Calculate data length. */ for (m = m0; m != NULL; m = m->m_next) { mprev = m; len += m->m_len; } /* * Make sure packet is actually of even length. */ if (len & 1) { m = mprev; if ((m->m_flags & M_EXT) == 0 && (m->m_len + m->m_data < &m->m_dat[MLEN])) { mtod(m, char*)[m->m_len++] = 0; } else { struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA); if (m1 == NULL) { m_freem(m0); return (ENOBUFS); } m1->m_len = 1; * mtod(m1, char *) = 0; m->m_next = m1; } m0->m_pkthdr.len++; } /* * Fill in mbuf with extended IPX header * and addresses and length put into network format. */ m = m0; if (ipxp->ipxp_flags & IPXP_RAWOUT) { ipx = mtod(m, struct ipx *); } else { M_PREPEND(m, sizeof(struct ipx), M_DONTWAIT); if (m == NULL) return (ENOBUFS); ipx = mtod(m, struct ipx *); ipx->ipx_tc = 0; ipx->ipx_pt = ipxp->ipxp_dpt; ipx->ipx_sna = ipxp->ipxp_laddr; ipx->ipx_dna = ipxp->ipxp_faddr; len += sizeof(struct ipx); } ipx->ipx_len = htons((u_short)len); if (ipxp->ipxp_flags & IPXP_CHECKSUM) { ipx->ipx_sum = ipx_cksum(m, len); } else ipx->ipx_sum = 0xffff; /* * Output datagram. */ so = ipxp->ipxp_socket; if (so->so_options & SO_DONTROUTE) return (ipx_outputfl(m, (struct route *)NULL, (so->so_options & SO_BROADCAST) | IPX_ROUTETOIF)); /* * Use cached route for previous datagram if * possible. If the previous net was the same * and the interface was a broadcast medium, or * if the previous destination was identical, * then we are ok. * * NB: We don't handle broadcasts because that * would require 3 subroutine calls. */ ro = &ipxp->ipxp_route; #ifdef ancient_history /* * I think that this will all be handled in ipx_pcbconnect! */ if (ro->ro_rt != NULL) { if(ipx_neteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) { /* * This assumes we have no GH type routes */ if (ro->ro_rt->rt_flags & RTF_HOST) { if (!ipx_hosteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) goto re_route; } if ((ro->ro_rt->rt_flags & RTF_GATEWAY) == 0) { - register struct ipx_addr *dst = + struct ipx_addr *dst = &satoipx_addr(ro->ro_dst); dst->x_host = ipx->ipx_dna.x_host; } /* * Otherwise, we go through the same gateway * and dst is already set up. */ } else { re_route: RTFREE(ro->ro_rt); ro->ro_rt = NULL; } } ipxp->ipxp_lastdst = ipx->ipx_dna; #endif /* ancient_history */ return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST)); } int -ipx_ctloutput(so, sopt) - struct socket *so; - struct sockopt *sopt; +ipx_ctloutput(struct socket *so, struct sockopt *sopt) { struct ipxpcb *ipxp = sotoipxpcb(so); int mask, error, optval; short soptval; struct ipx ioptval; long seq; KASSERT(ipxp != NULL, ("ipx_ctloutput: ipxp == NULL")); error = 0; switch (sopt->sopt_dir) { case SOPT_GET: switch (sopt->sopt_name) { case SO_ALL_PACKETS: mask = IPXP_ALL_PACKETS; goto get_flags; case SO_HEADERS_ON_INPUT: mask = IPXP_RAWIN; goto get_flags; case SO_IPX_CHECKSUM: mask = IPXP_CHECKSUM; goto get_flags; case SO_HEADERS_ON_OUTPUT: mask = IPXP_RAWOUT; get_flags: /* Unlocked read. */ soptval = ipxp->ipxp_flags & mask; error = sooptcopyout(sopt, &soptval, sizeof soptval); break; case SO_DEFAULT_HEADERS: ioptval.ipx_len = 0; ioptval.ipx_sum = 0; ioptval.ipx_tc = 0; IPX_LOCK(ipxp); ioptval.ipx_pt = ipxp->ipxp_dpt; ioptval.ipx_dna = ipxp->ipxp_faddr; ioptval.ipx_sna = ipxp->ipxp_laddr; IPX_UNLOCK(ipxp); error = sooptcopyout(sopt, &soptval, sizeof soptval); break; case SO_SEQNO: IPX_LIST_LOCK(); seq = ipx_pexseq; ipx_pexseq++; IPX_LIST_UNLOCK(); error = sooptcopyout(sopt, &seq, sizeof seq); break; default: error = EINVAL; } break; case SOPT_SET: switch (sopt->sopt_name) { case SO_ALL_PACKETS: mask = IPXP_ALL_PACKETS; goto set_head; case SO_HEADERS_ON_INPUT: mask = IPXP_RAWIN; goto set_head; case SO_IPX_CHECKSUM: mask = IPXP_CHECKSUM; case SO_HEADERS_ON_OUTPUT: mask = IPXP_RAWOUT; set_head: error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); if (error) break; IPX_LOCK(ipxp); if (optval) ipxp->ipxp_flags |= mask; else ipxp->ipxp_flags &= ~mask; IPX_UNLOCK(ipxp); break; case SO_DEFAULT_HEADERS: error = sooptcopyin(sopt, &ioptval, sizeof ioptval, sizeof ioptval); if (error) break; /* Unlocked write. */ ipxp->ipxp_dpt = ioptval.ipx_pt; break; #ifdef IPXIP case SO_IPXIP_ROUTE: error = ipxip_route(so, sopt); break; #endif /* IPXIP */ default: error = EINVAL; } break; } return (error); } static void -ipx_usr_abort(so) - struct socket *so; +ipx_usr_abort(struct socket *so) { /* XXXRW: Possibly ipx_disconnect() here? */ soisdisconnected(so); } static int -ipx_attach(so, proto, td) - struct socket *so; - int proto; - struct thread *td; +ipx_attach(struct socket *so, int proto, struct thread *td) { #ifdef INVARIANTS struct ipxpcb *ipxp = sotoipxpcb(so); #endif int error; KASSERT(ipxp == NULL, ("ipx_attach: ipxp != NULL")); error = soreserve(so, ipxsendspace, ipxrecvspace); if (error != 0) return (error); IPX_LIST_LOCK(); error = ipx_pcballoc(so, &ipxpcb_list, td); IPX_LIST_UNLOCK(); return (error); } static int -ipx_bind(so, nam, td) - struct socket *so; - struct sockaddr *nam; - struct thread *td; +ipx_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ipxpcb *ipxp = sotoipxpcb(so); int error; KASSERT(ipxp != NULL, ("ipx_bind: ipxp == NULL")); IPX_LIST_LOCK(); IPX_LOCK(ipxp); error = ipx_pcbbind(ipxp, nam, td); IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); return (error); } static void -ipx_usr_close(so) - struct socket *so; +ipx_usr_close(struct socket *so) { /* XXXRW: Possibly ipx_disconnect() here? */ soisdisconnected(so); } static int -ipx_connect(so, nam, td) - struct socket *so; - struct sockaddr *nam; - struct thread *td; +ipx_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ipxpcb *ipxp = sotoipxpcb(so); int error; KASSERT(ipxp != NULL, ("ipx_connect: ipxp == NULL")); IPX_LIST_LOCK(); IPX_LOCK(ipxp); if (!ipx_nullhost(ipxp->ipxp_faddr)) { error = EISCONN; goto out; } error = ipx_pcbconnect(ipxp, nam, td); if (error == 0) soisconnected(so); out: IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); return (error); } static void -ipx_detach(so) - struct socket *so; +ipx_detach(struct socket *so) { struct ipxpcb *ipxp = sotoipxpcb(so); /* XXXRW: Should assert detached. */ KASSERT(ipxp != NULL, ("ipx_detach: ipxp == NULL")); IPX_LIST_LOCK(); IPX_LOCK(ipxp); ipx_pcbdetach(ipxp); ipx_pcbfree(ipxp); IPX_LIST_UNLOCK(); } static int -ipx_disconnect(so) - struct socket *so; +ipx_disconnect(struct socket *so) { struct ipxpcb *ipxp = sotoipxpcb(so); int error; KASSERT(ipxp != NULL, ("ipx_disconnect: ipxp == NULL")); IPX_LIST_LOCK(); IPX_LOCK(ipxp); error = 0; if (ipx_nullhost(ipxp->ipxp_faddr)) { error = ENOTCONN; goto out; } ipx_pcbdisconnect(ipxp); soisdisconnected(so); out: IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); return (0); } int -ipx_peeraddr(so, nam) - struct socket *so; - struct sockaddr **nam; +ipx_peeraddr(struct socket *so, struct sockaddr **nam) { struct ipxpcb *ipxp = sotoipxpcb(so); KASSERT(ipxp != NULL, ("ipx_peeraddr: ipxp == NULL")); ipx_getpeeraddr(ipxp, nam); return (0); } static int -ipx_send(so, flags, m, nam, control, td) - struct socket *so; - int flags; - struct mbuf *m; - struct sockaddr *nam; - struct mbuf *control; - struct thread *td; +ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, + struct mbuf *control, struct thread *td) { int error; struct ipxpcb *ipxp = sotoipxpcb(so); struct ipx_addr laddr; KASSERT(ipxp != NULL, ("ipxp_send: ipxp == NULL")); /* * Attempt to only acquire the necessary locks: if the socket is * already connected, we don't need to hold the IPX list lock to be * used by ipx_pcbconnect() and ipx_pcbdisconnect(), just the IPX * pcb lock. */ if (nam != NULL) { IPX_LIST_LOCK(); IPX_LOCK(ipxp); laddr = ipxp->ipxp_laddr; if (!ipx_nullhost(ipxp->ipxp_faddr)) { IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); error = EISCONN; goto send_release; } /* * Must block input while temporarily connected. */ error = ipx_pcbconnect(ipxp, nam, td); if (error) { IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); goto send_release; } } else { IPX_LOCK(ipxp); if (ipx_nullhost(ipxp->ipxp_faddr)) { IPX_UNLOCK(ipxp); error = ENOTCONN; goto send_release; } } error = ipx_output(ipxp, m); m = NULL; if (nam != NULL) { ipx_pcbdisconnect(ipxp); ipxp->ipxp_laddr = laddr; IPX_UNLOCK(ipxp); IPX_LIST_UNLOCK(); } else IPX_UNLOCK(ipxp); send_release: if (m != NULL) m_freem(m); return (error); } static int ipx_shutdown(so) struct socket *so; { KASSERT(so->so_pcb != NULL, ("ipx_shutdown: so_pcb == NULL")); socantsendmore(so); return (0); } int -ipx_sockaddr(so, nam) - struct socket *so; - struct sockaddr **nam; +ipx_sockaddr(struct socket *so, struct sockaddr **nam) { struct ipxpcb *ipxp = sotoipxpcb(so); KASSERT(ipxp != NULL, ("ipx_sockaddr: ipxp == NULL")); ipx_getsockaddr(ipxp, nam); return (0); } static int -ripx_attach(so, proto, td) - struct socket *so; - int proto; - struct thread *td; +ripx_attach(struct socket *so, int proto, struct thread *td) { int error = 0; struct ipxpcb *ipxp = sotoipxpcb(so); KASSERT(ipxp == NULL, ("ripx_attach: ipxp != NULL")); if (td != NULL) { error = priv_check(td, PRIV_NETIPX_RAW); if (error) return (error); } /* * We hold the IPX list lock for the duration as address parameters * of the IPX pcb are changed. Since no one else holds a reference * to the ipxpcb yet, we don't need the ipxpcb lock here. */ IPX_LIST_LOCK(); error = ipx_pcballoc(so, &ipxrawpcb_list, td); if (error) goto out; ipxp = sotoipxpcb(so); error = soreserve(so, ipxsendspace, ipxrecvspace); if (error) goto out; ipxp->ipxp_faddr.x_host = ipx_broadhost; ipxp->ipxp_flags = IPXP_RAWIN | IPXP_RAWOUT; out: IPX_LIST_UNLOCK(); return (error); } diff --git a/sys/netipx/ipx_var.h b/sys/netipx/ipx_var.h index 61ad6ab063ce..1c76613f4501 100644 --- a/sys/netipx/ipx_var.h +++ b/sys/netipx/ipx_var.h @@ -1,131 +1,131 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ipx_var.h * * $FreeBSD$ */ #ifndef _NETIPX_IPX_VAR_H_ #define _NETIPX_IPX_VAR_H_ /* * IPX Kernel Structures and Variables */ struct ipxstat { u_long ipxs_total; /* total packets received */ u_long ipxs_badsum; /* checksum bad */ u_long ipxs_tooshort; /* packet too short */ u_long ipxs_toosmall; /* not enough data */ u_long ipxs_forward; /* packets forwarded */ u_long ipxs_cantforward; /* packets rcvd for unreachable dest */ u_long ipxs_delivered; /* datagrams delivered to upper level*/ u_long ipxs_localout; /* total ipx packets generated here */ u_long ipxs_odropped; /* lost packets due to nobufs, etc. */ u_long ipxs_noroute; /* packets discarded due to no route */ u_long ipxs_mtutoosmall; /* the interface mtu is too small */ }; #ifdef _KERNEL #ifdef SYSCTL_DECL SYSCTL_DECL(_net_ipx); SYSCTL_DECL(_net_ipx_ipx); #endif extern int ipxcksum; extern long ipx_pexseq; extern struct ipxstat ipxstat; extern struct pr_usrreqs ipx_usrreqs; extern struct pr_usrreqs ripx_usrreqs; extern struct sockaddr_ipx ipx_netmask; extern struct sockaddr_ipx ipx_hostmask; extern const union ipx_net ipx_zeronet; extern const union ipx_host ipx_zerohost; extern const union ipx_net ipx_broadnet; extern const union ipx_host ipx_broadhost; struct ifnet; struct ipx_addr; struct ipxpcb; struct mbuf; struct thread; struct route; struct sockaddr; struct socket; struct sockopt; u_short ipx_cksum(struct mbuf *m, int len); int ipx_control(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td); + struct ifnet *ifp, struct thread *td); void ipx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy); int ipx_ctloutput(struct socket *so, struct sockopt *sopt); void ipx_drop(struct ipxpcb *ipxp, int errno); void ipx_init(void); void ipx_input(struct mbuf *m, struct ipxpcb *ipxp); int ipx_outputfl(struct mbuf *m0, struct route *ro, int flags); int ipx_output_type20(struct mbuf *); int ipx_peeraddr(struct socket *so, struct sockaddr **nam); void ipx_printhost(struct ipx_addr *addr); int ipx_sockaddr(struct socket *so, struct sockaddr **nam); void ipx_watch_output(struct mbuf *m, struct ifnet *ifp); #endif /* _KERNEL */ #endif /* !_NETIPX_IPX_VAR_H_ */ diff --git a/sys/netipx/spx_debug.c b/sys/netipx/spx_debug.c index 7a210beb5fd3..1654bc02242b 100644 --- a/sys/netipx/spx_debug.c +++ b/sys/netipx/spx_debug.c @@ -1,196 +1,192 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)spx_debug.c */ #include __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_tcpdebug.h" #include #include #include #include #include #include #include #include #define SPXTIMERS #include #define SANAMES #include #ifdef TCPDEBUG static int spxconsdebug = 0; static struct spx_debug spx_debug[SPX_NDEBUG]; static int spx_debx; #endif /* * spx debug routines */ void -spx_trace(act, ostate, sp, si, req) - short act; - u_char ostate; - struct spxpcb *sp; - struct spx *si; - int req; +spx_trace(short act, u_char ostate, struct spxpcb *sp, struct spx *si, + int req) { #ifdef INET #ifdef TCPDEBUG u_short seq, ack, len, alo; int flags; struct spx_debug *sd = &spx_debug[spx_debx++]; if (spx_debx == SPX_NDEBUG) spx_debx = 0; sd->sd_time = iptime(); sd->sd_act = act; sd->sd_ostate = ostate; sd->sd_cb = (caddr_t)sp; if (sp != NULL) sd->sd_sp = *sp; else bzero((caddr_t)&sd->sd_sp, sizeof(*sp)); if (si != NULL) sd->sd_si = *si; else bzero((caddr_t)&sd->sd_si, sizeof(*si)); sd->sd_req = req; if (spxconsdebug == 0) return; if (ostate >= TCP_NSTATES) ostate = 0; if (act >= SA_DROP) act = SA_DROP; if (sp != NULL) printf("%p %s:", (void *)sp, tcpstates[ostate]); else printf("???????? "); printf("%s ", spxnames[act]); switch (act) { case SA_RESPOND: case SA_INPUT: case SA_OUTPUT: case SA_DROP: if (si == NULL) break; seq = si->si_seq; ack = si->si_ack; alo = si->si_alo; len = si->si_len; if (act == SA_OUTPUT) { seq = ntohs(seq); ack = ntohs(ack); alo = ntohs(alo); len = ntohs(len); } #ifndef lint #define p1(f) { printf("%s = %x, ", "f", f); } p1(seq); p1(ack); p1(alo); p1(len); #endif flags = si->si_cc; if (flags) { char *cp = "<"; #ifndef lint #define pf(f) { if (flags & SPX_ ## f) { printf("%s%s", cp, "f"); cp = ","; } } pf(SP); pf(SA); pf(OB); pf(EM); #else cp = cp; #endif printf(">"); } #ifndef lint #define p2(f) { printf("%s = %x, ", "f", si->si_ ## f); } p2(sid);p2(did);p2(dt);p2(pt); #endif ipx_printhost(&si->si_sna); ipx_printhost(&si->si_dna); if (act == SA_RESPOND) { printf("ipx_len = %x, ", ((struct ipx *)si)->ipx_len); } break; case SA_USER: printf("%s", prurequests[req&0xff]); if ((req & 0xff) == PRU_SLOWTIMO) printf("<%s>", spxtimers[req>>8]); break; } if (sp) printf(" -> %s", tcpstates[sp->s_state]); /* print out internal state of sp !?! */ printf("\n"); if (sp == 0) return; #ifndef lint #define p3(f) { printf("%s = %x, ", "f", sp->s_ ## f); } printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); #endif #endif #endif } diff --git a/sys/netipx/spx_debug.h b/sys/netipx/spx_debug.h index f91a7708c629..24a76f4a1ce8 100644 --- a/sys/netipx/spx_debug.h +++ b/sys/netipx/spx_debug.h @@ -1,104 +1,104 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1995, Mike Mitchell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)spx_debug.h * * $FreeBSD$ */ #ifndef _NETIPX_SPX_DEBUG_H_ #define _NETIPX_SPX_DEBUG_H_ struct spx_debug { u_long sd_time; short sd_act; short sd_ostate; caddr_t sd_cb; short sd_req; struct spx sd_si; struct spxpcb sd_sp; }; #define SA_INPUT 0 #define SA_OUTPUT 1 #define SA_USER 2 #define SA_RESPOND 3 #define SA_DROP 4 #ifdef SANAMES const char *spxnames[] = { "input", "output", "user", "respond", "drop" }; #endif #define SPX_NDEBUG 100 #ifndef _KERNEL /* XXX common variables for broken applications. */ struct spx_debug spx_debug[SPX_NDEBUG]; int spx_debx; #endif #ifdef _KERNEL extern char *prurequests[]; extern char *sanames[]; extern char *tcpstates[]; -void spx_trace(int act, int ostate, struct spxpcb *sp, struct spx *si, - int req); +void spx_trace(short act, u_char ostate, struct spxpcb *sp, struct spx *si, + int req); #endif #endif /* !_NETIPX_SPX_DEBUG_H_ */