Mega IPX commit.

Use the MAC address of an interface for the host part of an IPX address
and not the MAC address of the first interface for every IPX address.
This is more inline with the way others like Novell do it.
Mostly Submitted by: "Serge A. Babkin" <babkin@hq.icb.chel.su>

Take out the error messages (the ip icmp equivalent) with #ifdef IPXERRORMSGS.
This is bogus and as far as I could figure out IPX don't have anything like
it. This is a leftover from its XNS heritage. If nobody complains, I will
take it out completely in a few weeks.

Add some more ipxstat statistics counters.

Make ipxprintfs a sysctl variable and off by default.

Add IPX Netbios "routing" support. This is off by default and can be
switched on with a sysctl knob.

General code cleanup to at least use the same style throughout the IPX
code, but also be more style(9) conformant. Also make a lot of functions
static.

If I don't get any complaints I'll bring all of this over to the 2.2 tree
in a few weeks.
This commit is contained in:
John Hay 1997-05-10 09:58:58 +00:00
parent 5719a93caf
commit 8c7e2b93a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25652
21 changed files with 862 additions and 588 deletions

View File

@ -33,7 +33,7 @@
*
* @(#)ipx.c
*
* $Id: ipx.c,v 1.8 1997/03/24 11:33:31 bde Exp $
* $Id: ipx.c,v 1.9 1997/05/01 06:21:27 jhay Exp $
*/
#include <sys/param.h>
@ -52,16 +52,17 @@
#include <netipx/ipx.h>
#include <netipx/ipx_if.h>
#ifdef IPX
#include <netipx/ipx_var.h>
struct ipx_ifaddr *ipx_ifaddr;
int ipx_interfaces;
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).
*/
/* ARGSUSED */
int
ipx_control(so, cmd, data, ifp, p)
struct socket *so;
@ -81,22 +82,22 @@ ipx_control(so, cmd, data, ifp, p)
/*
* Find address for this interface, if it exists.
*/
if (ifp == 0)
if (ifp == NULL)
return (EADDRNOTAVAIL);
for (ia = ipx_ifaddr; ia; ia = ia->ia_next)
for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next)
if (ia->ia_ifp == ifp)
break;
switch (cmd) {
case SIOCGIFADDR:
if (ia == (struct ipx_ifaddr *)0)
if (ia == NULL)
return (EADDRNOTAVAIL);
*(struct sockaddr_ipx *)&ifr->ifr_addr = ia->ia_addr;
return (0);
case SIOCGIFBRDADDR:
if (ia == (struct ipx_ifaddr *)0)
if (ia == NULL)
return (EADDRNOTAVAIL);
if ((ifp->if_flags & IFF_BROADCAST) == 0)
return (EINVAL);
@ -104,7 +105,7 @@ ipx_control(so, cmd, data, ifp, p)
return (0);
case SIOCGIFDSTADDR:
if (ia == (struct ipx_ifaddr *)0)
if (ia == NULL)
return (EADDRNOTAVAIL);
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
@ -119,26 +120,26 @@ ipx_control(so, cmd, data, ifp, p)
case SIOCAIFADDR:
case SIOCDIFADDR:
if (ifra->ifra_addr.sipx_family == AF_IPX)
for (oia = ia; ia; ia = ia->ia_next) {
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 == 0)
if (cmd == SIOCDIFADDR && ia == NULL)
return (EADDRNOTAVAIL);
/* FALLTHROUGH */
case SIOCSIFADDR:
case SIOCSIFDSTADDR:
if (ia == (struct ipx_ifaddr *)0) {
if (ia == NULL) {
oia = (struct ipx_ifaddr *)
malloc(sizeof *ia, M_IFADDR, M_WAITOK);
if (oia == (struct ipx_ifaddr *)NULL)
malloc(sizeof(*ia), M_IFADDR, M_WAITOK);
if (oia == NULL)
return (ENOBUFS);
bzero((caddr_t)oia, sizeof(*oia));
if ((ia = ipx_ifaddr)) {
for ( ; ia->ia_next; ia = ia->ia_next)
if ((ia = ipx_ifaddr) != NULL) {
for ( ; ia->ia_next != NULL; ia = ia->ia_next)
;
ia->ia_next = oia;
} else
@ -157,7 +158,6 @@ ipx_control(so, cmd, data, ifp, p)
ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr);
ia->ia_broadaddr.sipx_addr.x_host = ipx_broadhost;
}
ipx_interfaces++;
}
}
@ -199,16 +199,11 @@ ipx_control(so, cmd, data, ifp, p)
printf("Didn't unlink ipxifadr from list\n");
}
IFAFREE((&oia->ia_ifa));
if (0 == --ipx_interfaces) {
/*
* We reset to virginity and start all over again
*/
ipx_thishost = ipx_zerohost;
}
return (0);
case SIOCAIFADDR:
dstIsNew = 0; hostIsNew = 1;
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;
@ -230,7 +225,7 @@ ipx_control(so, cmd, data, ifp, p)
return (error);
default:
if (ifp->if_ioctl == 0)
if (ifp->if_ioctl == NULL)
return (EOPNOTSUPP);
return ((*ifp->if_ioctl)(ifp, cmd, data));
}
@ -239,7 +234,7 @@ ipx_control(so, cmd, data, ifp, p)
/*
* Delete any previous route for an old address.
*/
void
static void
ipx_ifscrub(ifp, ia)
register struct ifnet *ifp;
register struct ipx_ifaddr *ia;
@ -256,7 +251,7 @@ ipx_ifscrub(ifp, ia)
* Initialize an interface's internet address
* and routing table entry.
*/
int
static int
ipx_ifinit(ifp, ia, sipx, scrub)
register struct ifnet *ifp;
register struct ipx_ifaddr *ia;
@ -264,7 +259,6 @@ ipx_ifinit(ifp, ia, sipx, scrub)
int scrub;
{
struct sockaddr_ipx oldaddr;
register union ipx_host *h = &ia->ia_addr.sipx_addr.x_host;
int s = splimp(), error;
/*
@ -272,45 +266,25 @@ ipx_ifinit(ifp, ia, sipx, scrub)
*/
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".
* if there is a single interface, use the address of that
* interface as our 6 byte host address.
* if there are multiple interfaces, use any address already
* used.
* 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 (ipx_hosteqnh(ipx_thishost, ipx_zerohost)) {
if (ifp->if_ioctl &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
}
ipx_thishost = *h;
} else if (ipx_hosteqnh(sipx->sipx_addr.x_host, ipx_zerohost)
|| ipx_hosteqnh(sipx->sipx_addr.x_host, ipx_thishost)) {
*h = ipx_thishost;
if (ifp->if_ioctl &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
}
if (!ipx_hosteqnh(ipx_thishost,*h)) {
ia->ia_addr = oldaddr;
splx(s);
return (EINVAL);
}
} else {
if (ifp->if_ioctl != NULL &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (EINVAL);
return (error);
}
splx(s);
ia->ia_ifa.ifa_metric = ifp->if_metric;
/*
* Add route for the network.
@ -340,11 +314,11 @@ ipx_iaonnetof(dst)
register struct ipx_ifaddr *ia;
register struct ipx_addr *compare;
register struct ifnet *ifp;
struct ipx_ifaddr *ia_maybe = 0;
struct ipx_ifaddr *ia_maybe = NULL;
union ipx_net net = dst->x_net;
for (ia = ipx_ifaddr; ia; ia = ia->ia_next) {
if ((ifp = ia->ia_ifp)) {
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))
@ -359,4 +333,3 @@ ipx_iaonnetof(dst)
}
return (ia_maybe);
}
#endif

View File

@ -33,7 +33,7 @@
*
* @(#)ipx.h
*
* $Id: ipx.h,v 1.10 1997/04/05 20:05:07 jhay Exp $
* $Id: ipx.h,v 1.11 1997/05/01 06:21:27 jhay Exp $
*/
#ifndef _NETIPX_IPX_H_
@ -46,31 +46,36 @@
/*
* Protocols
*/
#define IPXPROTO_UNKWN 0 /* Unknown */
#define IPXPROTO_RI 1 /* RIP Routing Information */
#define IPXPROTO_ECHO 2 /* Echo Protocol */
#define IPXPROTO_ERROR 3 /* Error Protocol */
#define IPXPROTO_PXP 4 /* PXP Packet Exchange */
#define IPXPROTO_SPX 5 /* SPX Sequenced Packet */
#define IPXPROTO_NCP 17 /* NCP NetWare Core */
#define IPXPROTO_RAW 255 /* Placemarker*/
#define IPXPROTO_MAX 256 /* Placemarker*/
#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_FSP 0x0451 /* NW FSP File Service */
#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 */
#define IPXPORT_WDOG 0x4001 /* NW Watchdog Packets */
#define IPXPORT_SHELL 0x4003 /* NW Shell Socket */
#define IPXPORT_MAX 0x8000 /* Maximum User Addressable Port */
#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 priveleged
*/
#define IPXPORT_RESERVED 0x4000
/*
* Ports > IPXPORT_WELLKNOWN are reserved for priveleged
* processes (e.g. root).
*/
#define IPXPORT_WELLKNOWN 0x6000
/* flags passed to ipx_outputfl as last parameter */
@ -127,7 +132,7 @@ struct sockaddr_ipx {
#define sipx_port sipx_addr.x_port
/*
* Definitions for IPX Internet Datagram Protocol
* Definitions for IPX Internetwork Packet Exchange Protocol
*/
struct ipx {
u_short ipx_sum; /* Checksum */
@ -142,73 +147,25 @@ struct ipx {
#define ipx_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */
#endif
#define ipx_neteqnn(a,b) \
(((a).s_net[0]==(b).s_net[0]) && ((a).s_net[1]==(b).s_net[1]))
(((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))
#ifdef KERNEL
extern struct pr_usrreqs ipx_usrreqs;
extern struct pr_usrreqs ripx_usrreqs;
extern int ipxcksum;
extern struct domain ipxdomain;
extern struct sockaddr_ipx ipx_netmask;
extern struct sockaddr_ipx ipx_hostmask;
extern union ipx_host ipx_thishost;
extern union ipx_net ipx_zeronet;
extern union ipx_host ipx_zerohost;
extern union ipx_net ipx_broadnet;
extern union ipx_host ipx_broadhost;
extern long ipx_pexseq;
extern u_char ipxctlerrmap[];
extern struct ipxpcb ipxrawpcb;
struct route;
struct sockaddr;
struct socket;
void ipx_abort __P((struct ipxpcb *ipxp));
u_short ipx_cksum __P((struct mbuf *m, int len));
int ipx_control __P((struct socket *so, int cmd, caddr_t data,
struct ifnet *ifp, struct proc *p));
void ipx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy));
int ipx_ctloutput __P((int req, struct socket *so, int level, int name,
struct mbuf **value, struct proc *p));
int ipx_do_route __P((struct ipx_addr *src, struct route *ro));
void ipx_drop __P((struct ipxpcb *ipxp, int errno));
void ipx_forward __P((struct mbuf *m));
void ipx_init __P((void));
void ipx_input __P((struct mbuf *m, struct ipxpcb *ipxp));
void ipxintr __P((void));
int ipx_output __P((struct ipxpcb *ipxp, struct mbuf *m0));
int ipx_outputfl __P((struct mbuf *m0, struct route *ro, int flags));
void ipx_undo_route __P((struct route *ro));
void ipx_watch_output __P((struct mbuf *m, struct ifnet *ifp));
int ipx_peeraddr __P((struct socket *so, struct mbuf *nam));
int ipx_sockaddr __P((struct socket *so, struct mbuf *nam));
#else
#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 <sys/cdefs.h>
__BEGIN_DECLS
struct ipx_addr
ipx_addr __P((const char *));
struct ipx_addr ipx_addr __P((const char *));
char *ipx_ntoa __P((struct ipx_addr));
__END_DECLS
#endif /* KERNEL */
#endif /* !_NETIPX_IPX_H_ */
#endif /* _NETIPX_IPX_H_ */

View File

@ -33,13 +33,18 @@
*
* @(#)ipx_cksum.c
*
* $Id$
* $Id: ipx_cksum.c,v 1.5 1997/02/22 09:41:52 peter Exp $
*/
#include <sys/param.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <net/route.h>
#include <netipx/ipx.h>
#include <netipx/ipx_var.h>
/*
* Checksum routine for Network Systems Protocol Packets (Big-Endian).
@ -66,7 +71,7 @@ ipx_cksum(m, len)
long l;
} l_util;
for (;m && len; m = m->m_next) {
for (;m != NULL && len; m = m->m_next) {
if (m->m_len == 0)
continue;
/*
@ -204,6 +209,7 @@ ipx_cksum(m, len)
* sum has already been kept to low sixteen bits.
* just examine result and exit.
*/
if(sum==0xffff) sum = 0;
if(sum == 0xffff)
sum = 0;
return (sum);
}

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_error.c
*
* $Id$
* $Id: ipx_error.c,v 1.7 1997/02/22 09:41:53 peter Exp $
*/
#include <sys/param.h>
@ -53,6 +53,8 @@
#include <netipx/ipx_pcb.h>
#include <netipx/ipx_error.h>
#ifdef IPXERRORMSGS
/*
* IPX_ERR routines: error generation, receive packet processing, and
* routines to turnaround packets back to the originator.
@ -108,7 +110,7 @@ ipx_error(om, type, param)
*/
if (type == IPX_ERR_NOSOCK &&
oip->ipx_dna.x_port == htons(2) &&
(type = ipx_echo(om))==0)
(type = ipx_echo(om)) == 0)
return;
if (ipx_errprintfs)
@ -164,12 +166,14 @@ ipx_error(om, type, param)
nip->ipx_sum = ipx_cksum(m, sizeof(*ep));
} else
nip->ipx_sum = 0xffff;
(void) ipx_outputfl(m, (struct route *)0, 0);
ipx_outputfl(m, (struct route *)NULL, 0);
freeit:
m_freem(om);
}
#endif /* IPXERRORMSGS */
void
ipx_printhost(addr)
register struct ipx_addr *addr;
@ -230,6 +234,8 @@ register struct ipx_addr *addr;
printf("%s.%s%s", net, host, cport);
}
#ifdef IPXERRORMSGS
/*
* Process a received IPX_ERR message.
*/
@ -253,9 +259,9 @@ ipx_err_input(m)
printf("%d\n", ntohs(epipx->ipx_ep_ipx.ipx_len));
}
i = sizeof (struct ipx_epipx);
i = sizeof(struct ipx_epipx);
if (((m->m_flags & M_EXT) || m->m_len < i) &&
(m = m_pullup(m, i)) == 0) {
(m = m_pullup(m, i)) == NULL) {
ipx_errstat.ipx_es_tooshort++;
return;
}
@ -359,10 +365,10 @@ struct mbuf *m;
} *ec = (struct echo *)ipx;
struct ipx_addr temp;
if (ipx->ipx_pt!=IPXPROTO_ECHO)
return(IPX_ERR_NOSOCK);
if (ec->ec_op!=htons(1))
return(IPX_ERR_UNSPEC);
if (ipx->ipx_pt != IPXPROTO_ECHO)
return (IPX_ERR_NOSOCK);
if (ec->ec_op != htons(1))
return (IPX_ERR_UNSPEC);
ec->ec_op = htons(2);
@ -373,12 +379,13 @@ struct mbuf *m;
if (ipxcksum && ipx->ipx_sum != 0xffff) {
ipx->ipx_sum = 0;
ipx->ipx_sum = ipx_cksum(m,
(int)(((ntohs(ipx->ipx_len) - 1)|1)+1));
(int)(((ntohs(ipx->ipx_len) - 1) | 1) + 1));
}
else
ipx->ipx_sum = 0xffff;
(void) ipx_outputfl(m, (struct route *)0, IPX_FORWARDING);
ipx_outputfl(m, (struct route *)NULL, IPX_FORWARDING);
return(0);
return (0);
}
#endif /* IPXERRORMSGS */

View File

@ -33,12 +33,14 @@
*
* @(#)ipx_error.h
*
* $Id$
* $Id: ipx_error.h,v 1.7 1997/02/22 09:41:53 peter Exp $
*/
#ifndef _NETIPX_IPX_ERROR_H_
#define _NETIPX_IPX_ERROR_H_
#ifdef IPXERRORMSGS
/*
* IPX error messages
*/
@ -77,13 +79,13 @@ struct ipx_epipx {
struct ipx_errstat {
/* statistics related to ipx_err packets generated */
int ipx_es_error; /* # of calls to ipx_error */
int ipx_es_oldshort; /* no error 'cuz old ip too short */
int ipx_es_oldshort; /* no error 'cuz old ip too short */
int ipx_es_oldipx_err; /* no error 'cuz old was ipx_err */
int ipx_es_outhist[IPX_ERR_MAX];
/* statistics related to input messages processed */
int ipx_es_badcode; /* ipx_err_code out of range */
int ipx_es_tooshort; /* packet < IPX_MINLEN */
int ipx_es_checksum; /* bad checksum */
int ipx_es_tooshort; /* packet < IPX_MINLEN */
int ipx_es_checksum; /* bad checksum */
int ipx_es_badlen; /* calculated bound mismatch */
int ipx_es_reflect; /* number of responses */
int ipx_es_inhist[IPX_ERR_MAX];
@ -91,14 +93,22 @@ struct ipx_errstat {
since we might not know all */
};
#endif
#ifdef KERNEL
#ifdef IPXERRORMSGS
extern u_char ipxctlerrmap[];
extern struct ipx_errstat ipx_errstat;
int ipx_echo __P((struct mbuf *m));
void ipx_err_input __P((struct mbuf *m));
int ipx_err_x __P((int c));
void ipx_error __P((struct mbuf *om, int type, int param));
void ipx_printhost __P((struct ipx_addr *addr));
#endif
#endif /* !_NETIPX_IPX_ERROR_H_ */
#endif
void ipx_printhost __P((struct ipx_addr *addr));
#endif /* KERNEL */
#endif /* _NETIPX_IPX_ERROR_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_if.h
*
* $Id$
* $Id: ipx_if.h,v 1.7 1997/02/22 09:41:53 peter Exp $
*/
#ifndef _NETIPX_IPX_IF_H_
@ -91,11 +91,7 @@ struct ipxip_req {
extern struct ifqueue ipxintrq; /* IPX input packet queue */
extern struct ipx_ifaddr *ipx_ifaddr;
struct ipx_ifaddr *
ipx_iaonnetof __P((struct ipx_addr *dst));
int ipx_ifinit __P((struct ifnet *ifp, struct ipx_ifaddr *ia,
struct sockaddr_ipx *sipx, int scrub));
void ipx_ifscrub __P((struct ifnet *ifp, struct ipx_ifaddr *ia));
#endif
struct ipx_ifaddr *ipx_iaonnetof __P((struct ipx_addr *dst));
#endif /* KERNEL */
#endif /* !_NETIPX_IPX_IF_H_ */
#endif /* _NETIPX_IPX_IF_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_input.c
*
* $Id$
* $Id: ipx_input.c,v 1.12 1997/02/22 09:41:54 peter Exp $
*/
#include <sys/param.h>
@ -62,48 +62,47 @@
#include <netipx/ipx_var.h>
#include <netipx/ipx_error.h>
#ifndef IPXPRINTFS
#define IPXPRINTFS 1 /* printing forwarding information */
#endif
int ipxcksum = 0;
int ipxcksum = 0;
SYSCTL_INT(_net_ipx_ipx, OID_AUTO, checksum, CTLFLAG_RW,
&ipxcksum, 0, "");
int ipxprintfs = IPXPRINTFS;
int ipxdonosocks = 0;
SYSCTL_INT(_net_ipx_ipx, OID_AUTO, donosocks, CTLFLAG_RW,
&ipxdonosocks, 0, "");
int ipxprintfs = 0; /* printing forwarding information */
SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxprintfs, CTLFLAG_RW,
&ipxprintfs, 0, "");
int ipxforwarding = 0;
int ipxforwarding = 0;
SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxforwarding, CTLFLAG_RW,
&ipxforwarding, 0, "");
union ipx_host ipx_thishost;
union ipx_net ipx_zeronet;
union ipx_host ipx_zerohost;
int ipxnetbios = 0;
SYSCTL_INT(_net_ipx, OID_AUTO, ipxnetbios, CTLFLAG_RW,
&ipxnetbios, 0, "");
union ipx_net ipx_broadnet;
union ipx_host ipx_broadhost;
union ipx_net ipx_zeronet;
union ipx_host ipx_zerohost;
struct ipxstat ipxstat;
struct sockaddr_ipx ipx_netmask, ipx_hostmask;
union ipx_net ipx_broadnet;
union ipx_host ipx_broadhost;
int ipxintr_getpck = 0;
int ipxintr_swtch = 0;
struct ipxstat ipxstat;
struct sockaddr_ipx ipx_netmask, ipx_hostmask;
static u_short allones[] = {-1, -1, -1};
static u_short allones[] = {-1, -1, -1};
struct ipxpcb ipxpcb;
struct ipxpcb ipxrawpcb;
struct ipxpcb ipxpcb;
struct ipxpcb ipxrawpcb;
struct ifqueue ipxintrq;
struct ifqueue ipxintrq;
int ipxqmaxlen = IFQ_MAXLEN;
long ipx_pexseq;
NETISR_SET(NETISR_IPX, ipxintr);
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);
/*
* IPX initialization.
*/
@ -111,8 +110,8 @@ NETISR_SET(NETISR_IPX, ipxintr);
void
ipx_init()
{
ipx_broadnet = * (union ipx_net *) allones;
ipx_broadhost = * (union ipx_host *) allones;
ipx_broadnet = *(union ipx_net *)allones;
ipx_broadhost = *(union ipx_host *)allones;
ipx_pexseq = time.tv_usec;
ipxintrq.ifq_maxlen = ipxqmaxlen;
@ -136,8 +135,9 @@ ipxintr()
register struct ipx *ipx;
register struct mbuf *m;
register struct ipxpcb *ipxp;
struct ipx_ifaddr *ia;
register int i;
int len, s, error;
int len, s;
char oddshortpacket = 0;
next:
@ -148,11 +148,19 @@ ipxintr()
s = splimp();
IF_DEQUEUE(&ipxintrq, m);
splx(s);
ipxintr_getpck++;
if (m == 0)
if (m == NULL)
return;
if ((m->m_flags & M_EXT || m->m_len < sizeof (struct ipx)) &&
(m = m_pullup(m, sizeof (struct ipx))) == 0) {
/*
* 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)
goto bad;
ipxstat.ipxs_total++;
if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) &&
(m = m_pullup(m, sizeof(struct ipx))) == 0) {
ipxstat.ipxs_toosmall++;
goto next;
}
@ -160,9 +168,11 @@ ipxintr()
/*
* Give any raw listeners a crack at the packet
*/
for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb; ipxp = ipxp->ipxp_next) {
for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb;
ipxp = ipxp->ipxp_next) {
struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL);
if (m1) ipx_input(m1, ipxp);
if (m1 != NULL)
ipx_input(m1, ipxp);
}
ipx = mtod(m, struct ipx *);
@ -193,19 +203,26 @@ ipxintr()
} else
m_adj(m, len - m->m_pkthdr.len);
}
if (ipxcksum && ((i = ipx->ipx_sum)!=0xffff)) {
if (ipxcksum && ((i = ipx->ipx_sum) != 0xffff)) {
ipx->ipx_sum = 0;
if (i != (ipx->ipx_sum = ipx_cksum(m, len))) {
ipxstat.ipxs_badsum++;
ipx->ipx_sum = i;
if (ipx_hosteqnh(ipx_thishost, ipx->ipx_dna.x_host))
error = IPX_ERR_BADSUM;
else
error = IPX_ERR_BADSUM_T;
ipx_error(m, error, 0);
goto next;
goto bad;
}
}
/*
* Propagated (Netbios) packets (type 20) has to be handled
* different. :-(
*/
if (ipx->ipx_pt == IPXPROTO_NETBIOS) {
if (ipxnetbios) {
ipx_output_type20(m);
goto next;
} else
goto bad;
}
/*
* Is this a directed broadcast?
*/
@ -214,6 +231,16 @@ ipxintr()
(!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
@ -232,10 +259,19 @@ ipxintr()
/*
* Is this our packet? If not, forward.
*/
} else if (!ipx_hosteqnh(ipx_thishost,ipx->ipx_dna.x_host)) {
ipx_forward(m);
goto next;
} 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);
goto next;
}
}
ours:
/*
* Locate pcb for datagram.
*/
@ -243,25 +279,31 @@ ipxintr()
/*
* Switch out to protocol's input routine.
*/
ipxintr_swtch++;
if (ipxp) {
if (ipxp != NULL) {
if (oddshortpacket) {
m_adj(m, -1);
}
if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS)==0)
ipxstat.ipxs_delivered++;
if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS) == 0)
switch (ipx->ipx_pt) {
case IPXPROTO_SPX:
spx_input(m, ipxp);
goto next;
#ifdef IPXERRORMSGS
case IPXPROTO_ERROR:
ipx_err_input(m);
goto next;
#endif
}
ipx_input(m, ipxp);
} else {
#ifdef IPXERRORMSGS
ipx_error(m, IPX_ERR_NOSOCK, 0);
#else
goto bad;
#endif
}
goto next;
@ -270,6 +312,7 @@ ipxintr()
goto next;
}
#ifdef IPXERRORMSGS
u_char ipxctlerrmap[PRC_NCMDS] = {
ECONNABORTED, ECONNABORTED, 0, 0,
0, 0, EHOSTDOWN, EHOSTUNREACH,
@ -277,6 +320,7 @@ u_char ipxctlerrmap[PRC_NCMDS] = {
EMSGSIZE, 0, 0, 0,
0, 0, 0, 0
};
#endif
void
ipx_ctlinput(cmd, arg_as_sa, dummy)
@ -286,16 +330,20 @@ ipx_ctlinput(cmd, arg_as_sa, dummy)
{
caddr_t arg = (/* XXX */ caddr_t)arg_as_sa;
struct ipx_addr *ipx;
#ifdef IPXERRORMSGS
struct ipxpcb *ipxp;
struct ipx_errp *errp;
int type;
#endif
if (cmd < 0 || cmd > PRC_NCMDS)
return;
#ifdef IPXERRORMSGS
if (ipxctlerrmap[cmd] == 0)
return; /* XXX */
type = IPX_ERR_UNREACH_HOST;
errp = (struct ipx_errp *)arg;
#endif
switch (cmd) {
struct sockaddr_ipx *sipx;
@ -309,11 +357,15 @@ ipx_ctlinput(cmd, arg_as_sa, dummy)
break;
default:
#ifdef IPXERRORMSGS
ipx = &errp->ipx_err_ipx.ipx_dna;
type = errp->ipx_err_num;
type = ntohs((u_short)type);
#endif
printf("ipx_ctlinput: cmd %d.\n", cmd);
break;
}
#ifdef IPXERRORMSGS
switch (type) {
case IPX_ERR_UNREACH_HOST:
@ -323,26 +375,38 @@ ipx_ctlinput(cmd, arg_as_sa, dummy)
case IPX_ERR_NOSOCK:
ipxp = ipx_pcblookup(ipx, errp->ipx_err_ipx.ipx_sna.x_port,
IPX_WILDCARD);
if(ipxp && ipxdonosocks && ! ipx_nullhost(ipxp->ipxp_faddr))
(void) ipx_drop(ipxp, (int)ipxctlerrmap[cmd]);
if(ipxp && ! ipx_nullhost(ipxp->ipxp_faddr))
ipx_drop(ipxp, (int)ipxctlerrmap[cmd]);
}
#endif
}
#ifdef IPXERRORMSGS
/*
* Forward a packet. If some error occurs return the sender
* an error packet. Note we can't always generate a meaningful
* error message because the IPX errors don't have a large enough repetoire
* of codes and types.
*/
#else
/*
* Forward a packet. If some error occurs drop the packet. IPX don't
* have a way to return errors to the sender.
*/
#endif
struct route ipx_droute;
struct route ipx_sroute;
void
static void
ipx_forward(m)
struct mbuf *m;
{
register struct ipx *ipx = mtod(m, struct ipx *);
register int error, type, code;
register int error;
#ifdef IPXERRORMSGS
int type, code;
#endif
struct mbuf *mcopy = NULL;
int agedelta = 1;
int flags = IPX_FORWARDING;
@ -351,23 +415,44 @@ struct mbuf *m;
if (ipxforwarding == 0) {
/* can't tell difference between net and host */
ipxstat.ipxs_cantforward++;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNREACH_HOST, code = 0;
goto senderror;
#else
m_freem(m);
goto cleanup;
#endif
}
ipx->ipx_tc++;
if (ipx->ipx_tc > IPX_MAXHOPS) {
ipxstat.ipxs_cantforward++;
#ifdef IPXERRORMSGS
type = IPX_ERR_TOO_OLD, code = 0;
goto senderror;
#else
m_freem(m);
goto cleanup;
#endif
}
#ifdef IPXERRORMSGS
/*
* Save at most 42 bytes of the packet in case
* we need to generate an IPX error message to the src.
*/
mcopy = m_copy(m, 0, imin((int)ntohs(ipx->ipx_len), 42));
#endif
if ((ok_there = ipx_do_route(&ipx->ipx_dna,&ipx_droute))==0) {
if ((ok_there = ipx_do_route(&ipx->ipx_dna,&ipx_droute)) == 0) {
ipxstat.ipxs_noroute++;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNREACH_HOST, code = 0;
goto senderror;
#else
m_freem(m);
goto cleanup;
#endif
}
/*
* Here we think about forwarding broadcast packets,
@ -379,26 +464,39 @@ struct mbuf *m;
if (ipx->ipx_dna.x_host.c_host[0] & 0x1) {
struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna);
struct ifnet *ifp;
if (ia) {
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) {
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) &&
(ifp = ipx_droute.ro_rt->rt_ifp) &&
ipx_sroute.ro_rt &&
(ifp!=ipx_sroute.ro_rt->rt_ifp)) {
(ifp != ipx_sroute.ro_rt->rt_ifp)) {
flags |= IPX_ALLOWBROADCAST;
} else {
ipxstat.ipxs_noroute++;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNREACH_HOST, code = 0;
goto senderror;
#else
m_freem(m);
goto cleanup;
#endif
}
}
/* XXX
* I think the checksum generation is bogus. According to the NLSP
* spec the ipx_tc (hop count) field and the ipx_sum should be
* zero'ed before generating the checksum, ie. it should not be
* necesary to recompute it in the forwarding function.
*/
/* need to adjust checksum */
if (ipxcksum && ipx->ipx_sum != 0xffff) {
union bytes {
@ -407,28 +505,35 @@ struct mbuf *m;
long l;
} x;
register int shift;
x.l = 0; x.c[0] = agedelta;
shift = (((((int)ntohs(ipx->ipx_len))+1)>>1)-2) & 0xf;
x.l = 0;
x.c[0] = agedelta;
shift = (((((int)ntohs(ipx->ipx_len)) + 1) >> 1) - 2) & 0xf;
x.l = ipx->ipx_sum + (x.s[0] << shift);
x.l = x.s[0] + x.s[1];
x.l = x.s[0] + x.s[1];
if (x.l==0xffff) ipx->ipx_sum = 0; else ipx->ipx_sum = x.l;
if (x.l == 0xffff)
ipx->ipx_sum = 0;
else
ipx->ipx_sum = x.l;
} else
ipx->ipx_sum = 0xffff;
error = ipx_outputfl(m, &ipx_droute, flags);
if (error == 0) {
ipxstat.ipxs_forward++;
if (ipxprintfs && !error) {
printf("forward: ");
ipx_printhost(&ipx->ipx_sna);
printf(" to ");
ipx_printhost(&ipx->ipx_dna);
printf(" hops %d\n", ipx->ipx_tc);
}
if (error && mcopy != NULL) {
if (ipxprintfs) {
printf("forward: ");
ipx_printhost(&ipx->ipx_sna);
printf(" to ");
ipx_printhost(&ipx->ipx_dna);
printf(" hops %d\n", ipx->ipx_tc);
}
} else if (mcopy != NULL) {
ipx = mtod(mcopy, struct ipx *);
#ifdef IPXERRORMSGS
type = IPX_ERR_UNSPEC_T, code = 0;
#endif
switch (error) {
case ENETUNREACH:
@ -436,21 +541,34 @@ struct mbuf *m;
case EHOSTUNREACH:
case ENETDOWN:
case EPERM:
ipxstat.ipxs_noroute++;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNREACH_HOST;
#endif
break;
case EMSGSIZE:
ipxstat.ipxs_mtutoosmall++;
#ifdef IPXERRORMSGS
type = IPX_ERR_TOO_BIG;
code = 576; /* too hard to figure out mtu here */
#endif
break;
case ENOBUFS:
ipxstat.ipxs_odropped++;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNSPEC_T;
#endif
break;
}
mcopy = NULL;
#ifdef IPXERRORMSGS
senderror:
ipx_error(m, type, code);
#else
m_freem(m);
#endif
}
cleanup:
if (ok_there)
@ -461,14 +579,14 @@ struct mbuf *m;
m_freem(mcopy);
}
int
static int
ipx_do_route(src, ro)
struct ipx_addr *src;
struct route *ro;
{
struct sockaddr_ipx *dst;
bzero((caddr_t)ro, sizeof (*ro));
bzero((caddr_t)ro, sizeof(*ro));
dst = (struct sockaddr_ipx *)&ro->ro_dst;
dst->sipx_len = sizeof(*dst);
@ -476,18 +594,20 @@ struct route *ro;
dst->sipx_addr = *src;
dst->sipx_addr.x_port = 0;
rtalloc(ro);
if (ro->ro_rt == 0 || ro->ro_rt->rt_ifp == 0) {
if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) {
return (0);
}
ro->ro_rt->rt_use++;
return (1);
}
void
static void
ipx_undo_route(ro)
register struct route *ro;
{
if (ro->ro_rt) {RTFREE(ro->ro_rt);}
if (ro->ro_rt != NULL) {
RTFREE(ro->ro_rt);
}
}
void
@ -497,24 +617,34 @@ struct ifnet *ifp;
{
register struct ipxpcb *ipxp;
register struct ifaddr *ifa;
register struct ipx_ifaddr *ia;
/*
* Give any raw listeners a crack at the packet
*/
for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb; ipxp = ipxp->ipxp_next) {
for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb;
ipxp = ipxp->ipxp_next) {
struct mbuf *m0 = m_copy(m, 0, (int)M_COPYALL);
if (m0) {
if (m0 != NULL) {
register struct ipx *ipx;
M_PREPEND(m0, sizeof (*ipx), M_DONTWAIT);
M_PREPEND(m0, sizeof(*ipx), M_DONTWAIT);
if (m0 == NULL)
continue;
ipx = mtod(m0, struct ipx *);
ipx->ipx_sna.x_net = ipx_zeronet;
ipx->ipx_sna.x_host = ipx_thishost;
if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
for(ifa = ifp->if_addrhead.tqh_first; ifa;
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))
for(ifa = ifp->if_addrhead.tqh_first; ifa != NULL;
ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family==AF_IPX) {
if (ifa->ifa_addr->sa_family == AF_IPX) {
ipx->ipx_sna = IA_SIPX(ifa)->sipx_addr;
break;
}

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_ip.c
*
* $Id: ipx_ip.c,v 1.13 1997/03/24 11:33:33 bde Exp $
* $Id: ipx_ip.c,v 1.14 1997/05/01 06:21:28 jhay Exp $
*/
/*
@ -68,11 +68,20 @@
#include <netipx/ipx.h>
#include <netipx/ipx_if.h>
#include <netipx/ipx_ip.h>
#include <netipx/ipx_var.h>
struct ifnet ipxipif;
struct ifnet_en *ipxip_list; /* list of all hosts and gateways or broadcast addrs */
struct ifnet ipxipif;
struct ifnet_en *ipxip_list; /* list of all hosts and gateways or broadcast addrs */
struct ifnet_en *
static struct ifnet_en *ipxipattach(void);
static int ipxip_free(struct ifnet *ifp);
static int ipxipioctl(struct ifnet *ifp, int cmd, caddr_t data);
static int ipxipoutput(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt);
static void ipxip_rtchange(struct in_addr *dst);
static void ipxipstart(struct ifnet *ifp);
static struct ifnet_en *
ipxipattach()
{
register struct ifnet_en *m;
@ -89,7 +98,8 @@ ipxipattach()
}
MALLOC((m), struct ifnet_en *, sizeof(*m), M_PCB, M_NOWAIT);
if (m == NULL) return (NULL);
if (m == NULL)
return (NULL);
bzero(m, sizeof(*m));
m->ifen_next = ipxip_list;
ipxip_list = m;
@ -111,8 +121,7 @@ ipxipattach()
/*
* Process an ioctl request.
*/
/* ARGSUSED */
int
static int
ipxipioctl(ifp, cmd, data)
register struct ifnet *ifp;
int cmd;
@ -160,7 +169,7 @@ ipxip_input(m, hlen)
int len, s;
if (ipxip_hold_input) {
if (ipxip_lastin) {
if (ipxip_lastin != NULL) {
m_freem(ipxip_lastin);
}
ipxip_lastin = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT);
@ -169,17 +178,17 @@ ipxip_input(m, hlen)
* Get IP and IPX header together in first mbuf.
*/
ipxipif.if_ipackets++;
s = sizeof (struct ip) + sizeof (struct ipx);
s = sizeof(struct ip) + sizeof(struct ipx);
if (((m->m_flags & M_EXT) || m->m_len < s) &&
(m = m_pullup(m, s)) == 0) {
(m = m_pullup(m, s)) == NULL) {
ipxipif.if_ierrors++;
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_hl > (sizeof (struct ip) >> 2)) {
ip_stripoptions(m, (struct mbuf *)0);
if (ip->ip_hl > (sizeof(struct ip) >> 2)) {
ip_stripoptions(m, (struct mbuf *)NULL);
if (m->m_len < s) {
if ((m = m_pullup(m, s)) == 0) {
if ((m = m_pullup(m, s)) == NULL) {
ipxipif.if_ierrors++;
return;
}
@ -191,16 +200,18 @@ ipxip_input(m, hlen)
* Make mbuf data length reflect IPX length.
* If not enough data to reflect IPX length, drop.
*/
m->m_data += sizeof (struct ip);
m->m_len -= sizeof (struct ip);
m->m_pkthdr.len -= sizeof (struct ip);
m->m_data += sizeof(struct ip);
m->m_len -= sizeof(struct ip);
m->m_pkthdr.len -= sizeof(struct ip);
ipx = mtod(m, struct ipx *);
len = ntohs(ipx->ipx_len);
if (len & 1) len++; /* Preserve Garbage Byte */
if (len & 1)
len++; /* Preserve Garbage Byte */
if (ip->ip_len != len) {
if (len > ip->ip_len) {
ipxipif.if_ierrors++;
if (ipxip_badlen) m_freem(ipxip_badlen);
if (ipxip_badlen)
m_freem(ipxip_badlen);
ipxip_badlen = m;
return;
}
@ -223,8 +234,7 @@ ipxip_input(m, hlen)
return;
}
/* ARGSUSED */
int
static int
ipxipoutput(ifp, m, dst, rt)
struct ifnet *ifp;
register struct mbuf *m;
@ -246,25 +256,26 @@ ipxipoutput(ifp, m, dst, rt)
* for IP header.
*/
len = ntohs(ipx->ipx_len);
if (len & 1) len++; /* Preserve Garbage Byte */
if (len & 1)
len++; /* Preserve Garbage Byte */
/* following clause not necessary on vax */
if (3 & (int)m->m_data) {
/* force longword alignment of ip hdr */
struct mbuf *m0 = m_gethdr(MT_HEADER, M_DONTWAIT);
if (m0 == 0) {
if (m0 == NULL) {
m_freem(m);
return (ENOBUFS);
}
MH_ALIGN(m0, sizeof (struct ip));
MH_ALIGN(m0, sizeof(struct ip));
m0->m_flags = m->m_flags & M_COPYFLAGS;
m0->m_next = m;
m0->m_len = sizeof (struct ip);
m0->m_len = sizeof(struct ip);
m0->m_pkthdr.len = m0->m_len + m->m_len;
m->m_flags &= ~M_PKTHDR;
m = m0;
} else {
M_PREPEND(m, sizeof (struct ip), M_DONTWAIT);
if (m == 0)
M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
if (m == NULL)
return (ENOBUFS);
}
/*
@ -275,13 +286,13 @@ ipxipoutput(ifp, m, dst, rt)
ip->ip_p = IPPROTO_IDP;
ip->ip_src = ifn->ifen_src;
ip->ip_dst = ifn->ifen_dst;
ip->ip_len = (u_short)len + sizeof (struct ip);
ip->ip_len = (u_short)len + sizeof(struct ip);
ip->ip_ttl = MAXTTL;
/*
* Output final datagram.
*/
error = (ip_output(m, (struct mbuf *)0, ro, SO_BROADCAST, NULL));
error = (ip_output(m, (struct mbuf *)NULL, ro, SO_BROADCAST, NULL));
if (error) {
ifn->ifen_ifnet.if_oerrors++;
ifn->ifen_ifnet.if_ierrors = error;
@ -291,7 +302,7 @@ ipxipoutput(ifp, m, dst, rt)
return (ENETUNREACH);
}
void
static void
ipxipstart(ifp)
struct ifnet *ifp;
{
@ -316,15 +327,15 @@ ipxip_route(so, m, p)
/*
* First, make sure we already have an IPX address:
*/
if (ipx_hosteqnh(ipx_thishost, ipx_zerohost))
if (ipx_ifaddr == NULL)
return (EADDRNOTAVAIL);
/*
* Now, determine if we can get to the destination
*/
bzero((caddr_t)&ro, sizeof (ro));
bzero((caddr_t)&ro, sizeof(ro));
ro.ro_dst = *(struct sockaddr *)ip_dst;
rtalloc(&ro);
if (ro.ro_rt == 0 || ro.ro_rt->rt_ifp == 0) {
if (ro.ro_rt == NULL || ro.ro_rt->rt_ifp == NULL) {
return (ENETUNREACH);
}
@ -336,13 +347,13 @@ ipxip_route(so, m, p)
register struct in_ifaddr *ia;
struct ifnet *ifp = ro.ro_rt->rt_ifp;
for (ia = in_ifaddrhead.tqh_first; ia;
for (ia = in_ifaddrhead.tqh_first; ia != NULL;
ia = ia->ia_link.tqe_next)
if (ia->ia_ifp == ifp)
break;
if (ia == 0)
if (ia == NULL)
ia = in_ifaddrhead.tqh_first;
if (ia == 0) {
if (ia == NULL) {
RTFREE(ro.ro_rt);
return (EADDRNOTAVAIL);
}
@ -352,7 +363,7 @@ ipxip_route(so, m, p)
/*
* Is there a free (pseudo-)interface or space?
*/
for (ifn = ipxip_list; ifn; ifn = ifn->ifen_next) {
for (ifn = ipxip_list; ifn != NULL; ifn = ifn->ifen_next) {
if ((ifn->ifen_ifnet.if_flags & IFF_UP) == 0)
break;
}
@ -370,24 +381,29 @@ ipxip_route(so, m, p)
* now configure this as a point to point link
*/
ifr_ipxip.ifr_name[4] = '0' + ipxipif.if_unit - 1;
ifr_ipxip.ifr_dstaddr = * (struct sockaddr *) ipx_dst;
(void)ipx_control(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip,
ifr_ipxip.ifr_dstaddr = *(struct sockaddr *)ipx_dst;
ipx_control(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip,
(struct ifnet *)ifn, p);
satoipx_addr(ifr_ipxip.ifr_addr).x_host = ipx_thishost;
/* use any our address */
#if XXX_Hmmmm
if (ia != NULL)
satoipx_addr(ifr_ipxip.ifr_addr).x_host =
ipx_ifaddr->ia_addr.sipx_addr.x_host;
#endif
return (ipx_control(so, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip,
(struct ifnet *)ifn, p));
}
int
static int
ipxip_free(ifp)
struct ifnet *ifp;
{
register struct ifnet_en *ifn = (struct ifnet_en *)ifp;
struct route *ro = & ifn->ifen_route;
if (ro->ro_rt) {
if (ro->ro_rt != NULL) {
RTFREE(ro->ro_rt);
ro->ro_rt = 0;
ro->ro_rt = NULL;
}
ifp->if_flags &= ~IFF_UP;
return (0);
@ -399,9 +415,7 @@ ipxip_ctlinput(cmd, sa, dummy)
struct sockaddr *sa;
void *dummy;
{
/*extern u_char inetctlerrmap[]; */ /*XXX*/ /*JRE*/
struct sockaddr_in *sin;
/* int in_rtchange(); */ /*XXX*/ /*JRE*/
if ((unsigned)cmd >= PRC_NCMDS)
return;
@ -423,18 +437,18 @@ ipxip_ctlinput(cmd, sa, dummy)
}
}
void
static void
ipxip_rtchange(dst)
register struct in_addr *dst;
{
register struct ifnet_en *ifn;
for (ifn = ipxip_list; ifn; ifn = ifn->ifen_next) {
for (ifn = ipxip_list; ifn != NULL; ifn = ifn->ifen_next) {
if (ifn->ifen_dst.s_addr == dst->s_addr &&
ifn->ifen_route.ro_rt) {
ifn->ifen_route.ro_rt != NULL) {
RTFREE(ifn->ifen_route.ro_rt);
ifn->ifen_route.ro_rt = 0;
ifn->ifen_route.ro_rt = NULL;
}
}
}
#endif
#endif /* IPXIP */

View File

@ -33,7 +33,7 @@
*
* @(#)ipxip.h
*
* $Id: ipx_ip.h,v 1.8 1997/02/22 09:41:55 peter Exp $
* $Id: ipx_ip.h,v 1.9 1997/05/01 06:21:28 jhay Exp $
*/
#ifndef _NETIPX_IPXIP_H_
@ -51,21 +51,10 @@ struct ifnet_en {
#ifdef KERNEL
extern struct ifnet ipxipif;
extern struct ifnet_en *ipxip_list;
struct ifnet_en *
ipxipattach __P((void));
void ipxip_ctlinput __P((int cmd, struct sockaddr *sa, void *arg));
int ipxip_free __P((struct ifnet *ifp));
void ipxip_input __P((struct mbuf *m, int hlen));
int ipxipioctl __P((struct ifnet *ifp, int cmd, caddr_t data));
int ipxipoutput __P((struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt));
int ipxip_route __P((struct socket *so, struct mbuf *m, struct proc *p));
void ipxip_rtchange __P((struct in_addr *dst));
void ipxipstart __P((struct ifnet *ifp));
#endif /* KERNEL */
#endif /* !_NETIPX_IPXIP_H_ */
#endif /* _NETIPX_IPXIP_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_outputfl.c
*
* $Id$
* $Id: ipx_outputfl.c,v 1.6 1997/02/22 09:41:55 peter Exp $
*/
#include <sys/param.h>
@ -56,10 +56,7 @@
#include <machine/mtpr.h>
#endif
int ipx_hold_output = 0;
int ipx_copy_output = 0;
int ipx_outputfl_cnt = 0;
struct mbuf *ipx_lastout;
int ipx_copy_output = 0;
int
ipx_outputfl(m0, ro, flags)
@ -68,28 +65,22 @@ ipx_outputfl(m0, ro, flags)
int flags;
{
register struct ipx *ipx = mtod(m0, struct ipx *);
register struct ifnet *ifp = 0;
register struct ifnet *ifp = NULL;
int error = 0;
struct sockaddr_ipx *dst;
struct route ipxroute;
if (ipx_hold_output) {
if (ipx_lastout) {
(void)m_free(ipx_lastout);
}
ipx_lastout = m_copy(m0, 0, (int)M_COPYALL);
}
/*
* Route packet.
*/
if (ro == 0) {
if (ro == NULL) {
ro = &ipxroute;
bzero((caddr_t)ro, sizeof (*ro));
bzero((caddr_t)ro, sizeof(*ro));
}
dst = (struct sockaddr_ipx *)&ro->ro_dst;
if (ro->ro_rt == 0) {
if (ro->ro_rt == NULL) {
dst->sipx_family = AF_IPX;
dst->sipx_len = sizeof (*dst);
dst->sipx_len = sizeof(*dst);
dst->sipx_addr = ipx->ipx_dna;
dst->sipx_addr.x_port = 0;
/*
@ -99,7 +90,8 @@ ipx_outputfl(m0, ro, flags)
if (flags & IPX_ROUTETOIF) {
struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna);
if (ia == 0) {
if (ia == NULL) {
ipxstat.ipxs_noroute++;
error = ENETUNREACH;
goto bad;
}
@ -115,7 +107,8 @@ ipx_outputfl(m0, ro, flags)
ro->ro_rt = NULL;
rtalloc(ro);
}
if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
if (ro->ro_rt == NULL || (ifp = ro->ro_rt->rt_ifp) == NULL) {
ipxstat.ipxs_noroute++;
error = ENETUNREACH;
goto bad;
}
@ -140,23 +133,138 @@ ipx_outputfl(m0, ro, flags)
}
if (htons(ipx->ipx_len) <= ifp->if_mtu) {
ipx_outputfl_cnt++;
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 error = EMSGSIZE;
} 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) {
if (ro == &ipxroute && (flags & IPX_ROUTETOIF) == 0 &&
ro->ro_rt != NULL) {
RTFREE(ro->ro_rt);
ro->ro_rt = 0;
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;
{
register struct ipx *ipx;
union ipx_net *nbnet = (union ipx_net *)(ipx + 1);
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;i<ipx->ipx_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;i<ipx->ipx_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;
m1 = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
if(ipx->ipx_sum != 0xffff) {
int len = ntohs(ipx->ipx_len);
ipx->ipx_sum = 0;
len = ((len - 1) | 1) + 1;
ipx->ipx_sum = ipx_cksum(m, len);
}
if(m1) {
error = (*ifp->if_output)(ifp, m1,
(struct sockaddr *)&dst, NULL);
/* XXX ipxstat.ipxs_localout++; */
}
skip_this:
}
bad:
m_freem(m);
return (error);
}

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_pcb.c
*
* $Id: ipx_pcb.c,v 1.7 1997/02/22 09:41:56 peter Exp $
* $Id: ipx_pcb.c,v 1.8 1997/05/01 06:21:29 jhay Exp $
*/
#include <sys/param.h>
@ -52,6 +52,7 @@
#include <netipx/ipx.h>
#include <netipx/ipx_if.h>
#include <netipx/ipx_pcb.h>
#include <netipx/ipx_var.h>
struct ipx_addr zeroipx_addr;
@ -85,10 +86,10 @@ ipx_pcbbind(ipxp, nam, p)
if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr))
return (EINVAL);
if (nam == 0)
if (nam == NULL)
goto noname;
sipx = mtod(nam, struct sockaddr_ipx *);
if (nam->m_len != sizeof (*sipx))
if (nam->m_len != sizeof(*sipx))
return (EINVAL);
if (!ipx_nullhost(sipx->sipx_addr)) {
int tport = sipx->sipx_port;
@ -103,8 +104,8 @@ ipx_pcbbind(ipxp, nam, p)
u_short aport = ntohs(lport);
int error;
if (aport < IPXPORT_MAX &&
p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
if (aport < IPXPORT_RESERVED &&
p != NULL && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (ipx_pcblookup(&zeroipx_addr, lport, 0))
return (EADDRINUSE);
@ -113,8 +114,10 @@ ipx_pcbbind(ipxp, nam, p)
noname:
if (lport == 0)
do {
if (ipxpcb.ipxp_lport++ < IPXPORT_MAX)
ipxpcb.ipxp_lport = IPXPORT_MAX;
ipxpcb.ipxp_lport++;
if ((ipxpcb.ipxp_lport < IPXPORT_RESERVED) ||
(ipxpcb.ipxp_lport >= IPXPORT_WELLKNOWN))
ipxpcb.ipxp_lport = IPXPORT_RESERVED;
lport = htons(ipxpcb.ipxp_lport);
} while (ipx_pcblookup(&zeroipx_addr, lport, 0));
ipxp->ipxp_lport = lport;
@ -139,11 +142,13 @@ ipx_pcbconnect(ipxp, nam, p)
register struct route *ro;
struct ifnet *ifp;
if (nam->m_len != sizeof (*sipx))
ia = NULL;
if (nam->m_len != sizeof(*sipx))
return (EINVAL);
if (sipx->sipx_family != AF_IPX)
return (EAFNOSUPPORT);
if (sipx->sipx_port==0 || ipx_nullhost(sipx->sipx_addr))
if (sipx->sipx_port == 0 || ipx_nullhost(sipx->sipx_addr))
return (EADDRNOTAVAIL);
/*
* If we haven't bound which network number to use as ours,
@ -164,21 +169,20 @@ ipx_pcbconnect(ipxp, nam, p)
if (!ipx_neteq(ipxp->ipxp_lastdst, sipx->sipx_addr))
goto flush;
if (!ipx_hosteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) {
if (ro->ro_rt && ! (ro->ro_rt->rt_flags & RTF_HOST)) {
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)
if (ro->ro_rt != NULL)
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)0;
ro->ro_rt = NULL;
ipxp->ipxp_laddr.x_net = ipx_zeronet;
}
}/* 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 == (struct rtentry *)0 ||
ro->ro_rt->rt_ifp == (struct ifnet *)0)) {
(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);
@ -192,37 +196,65 @@ ipx_pcbconnect(ipxp, nam, p)
* our src addr is taken from the i/f, else punt.
*/
ia = (struct ipx_ifaddr *)0;
/*
* If we found a route, use the address
* corresponding to the outgoing interface
*/
if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp))
for (ia = ipx_ifaddr; ia; ia = ia->ia_next)
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 == 0) {
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 == 0)
if (ia == NULL)
ia = ipx_iaonnetof(&sipx->sipx_addr);
if (ia == 0)
if (ia == NULL)
ia = ipx_ifaddr;
if (ia == 0)
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 (ipx_nullhost(ipxp->ipxp_laddr)) {
if (ipxp->ipxp_lport == 0)
(void) ipx_pcbbind(ipxp, (struct mbuf *)0, p);
ipxp->ipxp_laddr.x_host = ipx_thishost;
}
if (ipxp->ipxp_lport == 0)
ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
/* 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);
@ -246,10 +278,10 @@ ipx_pcbdetach(ipxp)
so->so_pcb = 0;
sofree(so);
if (ipxp->ipxp_route.ro_rt)
if (ipxp->ipxp_route.ro_rt != NULL)
rtfree(ipxp->ipxp_route.ro_rt);
remque(ipxp);
(void) m_free(dtom(ipxp));
m_free(dtom(ipxp));
}
void
@ -259,9 +291,9 @@ ipx_setsockaddr(ipxp, nam)
{
register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *);
nam->m_len = sizeof (*sipx);
nam->m_len = sizeof(*sipx);
sipx = mtod(nam, struct sockaddr_ipx *);
bzero((caddr_t)sipx, sizeof (*sipx));
bzero((caddr_t)sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_laddr;
@ -274,9 +306,9 @@ ipx_setpeeraddr(ipxp, nam)
{
register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *);
nam->m_len = sizeof (*sipx);
nam->m_len = sizeof(*sipx);
sipx = mtod(nam, struct sockaddr_ipx *);
bzero((caddr_t)sipx, sizeof (*sipx));
bzero((caddr_t)sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_faddr;
@ -325,9 +357,9 @@ ipx_pcbnotify(dst, errno, notify, param)
ipx_rtchange(ipxp)
struct ipxpcb *ipxp;
{
if (ipxp->ipxp_route.ro_rt) {
if (ipxp->ipxp_route.ro_rt != NULL) {
rtfree(ipxp->ipxp_route.ro_rt);
ipxp->ipxp_route.ro_rt = 0;
ipxp->ipxp_route.ro_rt = NULL;
/*
* A new route can be allocated the next time
* output is attempted.
@ -369,7 +401,7 @@ ipx_pcblookup(faddr, lport, wildp)
}
}
}
if (wildcard && wildp==0)
if (wildcard && wildp == 0)
continue;
if (wildcard < matchwild) {
match = ipxp;

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_pcb.h
*
* $Id: ipx_pcb.h,v 1.8 1997/02/22 09:41:56 peter Exp $
* $Id: ipx_pcb.h,v 1.9 1997/05/01 06:21:29 jhay Exp $
*/
#ifndef _NETIPX_IPX_PCB_H_
@ -60,12 +60,12 @@ struct ipxpcb {
/* possible 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_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 IPX_WILDCARD 1
#define IPX_WILDCARD 1
#define ipxp_lport ipxp_laddr.x_port
#define ipxp_fport ipxp_faddr.x_port
@ -95,6 +95,6 @@ void ipx_pcbnotify __P((struct ipx_addr *dst, int errno,
void (*notify)(struct ipxpcb *), long param));
void ipx_setpeeraddr __P((struct ipxpcb *ipxp, struct mbuf *nam));
void ipx_setsockaddr __P((struct ipxpcb *ipxp, struct mbuf *nam));
#endif
#endif /* KERNEL */
#endif /* !_NETIPX_IPX_PCB_H_ */
#endif /* _NETIPX_IPX_PCB_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_proto.c
*
* $Id: ipx_proto.c,v 1.8 1997/04/05 20:05:08 jhay Exp $
* $Id: ipx_proto.c,v 1.9 1997/05/01 12:24:20 jhay Exp $
*/
#include <sys/param.h>
@ -42,14 +42,18 @@
#include <sys/domain.h>
#include <sys/kernel.h>
#include <sys/mbuf.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <net/radix.h>
#include <net/route.h>
#include <netipx/ipx.h>
#include <netipx/ipx_var.h>
#include <netipx/spx.h>
static struct pr_usrreqs nousrreqs;
extern struct domain ipxdomain;
static struct pr_usrreqs nousrreqs;
/*
* IPX protocol family: IPX, ERR, PXP, SPX, ROUTE.
@ -86,12 +90,14 @@ struct protosw ipxsw[] = {
0, 0, 0, 0,
&ripx_usrreqs
},
#ifdef IPXERRORMSGS
{ SOCK_RAW, &ipxdomain, IPXPROTO_ERROR, PR_ATOMIC|PR_ADDR,
0, 0, 0, ipx_ctloutput,
0,
0, 0, 0, 0,
&ripx_usrreqs
},
#endif
#ifdef IPTUNNEL
#if 0
{ SOCK_RAW, &ipxdomain, IPPROTO_IPX, PR_ATOMIC|PR_ADDR,
@ -104,7 +110,7 @@ struct protosw ipxsw[] = {
#endif
};
struct domain ipxdomain =
struct domain ipxdomain =
{ AF_IPX, "network systems", 0, 0, 0,
ipxsw, &ipxsw[sizeof(ipxsw)/sizeof(ipxsw[0])], 0,
rn_inithead, 16, sizeof(struct sockaddr_ipx)};
@ -115,5 +121,7 @@ SYSCTL_NODE(_net, PF_IPX, ipx, CTLFLAG_RW, 0,
SYSCTL_NODE(_net_ipx, IPXPROTO_RAW, ipx, CTLFLAG_RW, 0, "IPX");
SYSCTL_NODE(_net_ipx, IPXPROTO_SPX, spx, CTLFLAG_RW, 0, "SPX");
#ifdef IPXERRORMSGS
SYSCTL_NODE(_net_ipx, IPXPROTO_ERROR, error, CTLFLAG_RW, 0,
"Error Protocol");
#endif

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_usrreq.c
*
* $Id: ipx_usrreq.c,v 1.12 1997/04/05 20:05:09 jhay Exp $
* $Id: ipx_usrreq.c,v 1.13 1997/05/01 06:21:30 jhay Exp $
*/
#include <sys/param.h>
@ -66,8 +66,6 @@
* IPX protocol implementation.
*/
int noipxRoute;
int ipxsendspace = IPXSNDQ;
SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxsendspace, CTLFLAG_RW,
&ipxsendspace, 0, "");
@ -85,21 +83,22 @@ static int ipx_send(struct socket *so, int flags, struct mbuf *m,
struct mbuf *addr, struct mbuf *control, struct proc *p);
static int ipx_shutdown(struct socket *so);
static int ripx_attach(struct socket *so, int proto, struct proc *p);
static int ipx_output(struct ipxpcb *ipxp, struct mbuf *m0);
struct pr_usrreqs ipx_usrreqs = {
struct pr_usrreqs ipx_usrreqs = {
ipx_usr_abort, pru_accept_notsupp, ipx_attach, ipx_bind,
ipx_connect, pru_connect2_notsupp, ipx_control, ipx_detach,
ipx_disconnect, pru_listen_notsupp, ipx_peeraddr, pru_rcvd_notsupp,
pru_rcvoob_notsupp, ipx_send, pru_sense_null, ipx_shutdown,
ipx_sockaddr
ipx_sockaddr, sosend, soreceive, soselect
};
struct pr_usrreqs ripx_usrreqs = {
struct pr_usrreqs ripx_usrreqs = {
ipx_usr_abort, pru_accept_notsupp, ripx_attach, ipx_bind,
ipx_connect, pru_connect2_notsupp, ipx_control, ipx_detach,
ipx_disconnect, pru_listen_notsupp, ipx_peeraddr, pru_rcvd_notsupp,
pru_rcvoob_notsupp, ipx_send, pru_sense_null, ipx_shutdown,
ipx_sockaddr
ipx_sockaddr, sosend, soreceive, soselect
};
/*
@ -114,7 +113,7 @@ ipx_input(m, ipxp)
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct sockaddr_ipx ipx_ipx;
if (ipxp==0)
if (ipxp == NULL)
panic("No ipxpcb");
/*
* Construct sockaddr format source address.
@ -125,10 +124,10 @@ ipx_input(m, ipxp)
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) {
if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp != NULL) {
register struct ifaddr *ifa;
for (ifa = ifp->if_addrhead.tqh_first; ifa;
for (ifa = ifp->if_addrhead.tqh_first; ifa != NULL;
ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family == AF_IPX) {
ipx_ipx.sipx_addr.x_net =
@ -138,13 +137,13 @@ ipx_input(m, ipxp)
}
}
ipxp->ipxp_rpt = ipx->ipx_pt;
if ( ! (ipxp->ipxp_flags & IPXP_RAWIN) ) {
m->m_len -= sizeof (struct ipx);
m->m_pkthdr.len -= sizeof (struct ipx);
m->m_data += sizeof (struct ipx);
if (!(ipxp->ipxp_flags & IPXP_RAWIN) ) {
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, (struct mbuf *)0) == 0)
m, (struct mbuf *)NULL) == 0)
goto bad;
sorwakeup(ipxp->ipxp_socket);
return;
@ -161,11 +160,11 @@ ipx_abort(ipxp)
ipx_pcbdisconnect(ipxp);
soisdisconnected(so);
}
/*
* Drop connection, reporting
* the specified error.
*/
/* struct ipxpcb * DELETE THIS */
void
ipx_drop(ipxp, errno)
register struct ipxpcb *ipxp;
@ -174,20 +173,22 @@ ipx_drop(ipxp, errno)
struct socket *so = ipxp->ipxp_socket;
/*
* someday, in the xerox world
* 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;
(void) tcp_output(tp);
tcp_output(tp);
}*/
so->so_error = errno;
ipx_pcbdisconnect(ipxp);
soisdisconnected(so);
}
int
static int
ipx_output(ipxp, m0)
struct ipxpcb *ipxp;
struct mbuf *m0;
@ -202,7 +203,7 @@ ipx_output(ipxp, m0)
/*
* Calculate data length.
*/
for (m = m0; m; m = m->m_next) {
for (m = m0; m != NULL; m = m->m_next) {
mprev = m;
len += m->m_len;
}
@ -218,7 +219,7 @@ ipx_output(ipxp, m0)
} else {
struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
if (m1 == 0) {
if (m1 == NULL) {
m_freem(m0);
return (ENOBUFS);
}
@ -237,15 +238,15 @@ ipx_output(ipxp, m0)
if (ipxp->ipxp_flags & IPXP_RAWOUT) {
ipx = mtod(m, struct ipx *);
} else {
M_PREPEND(m, sizeof (struct ipx), M_DONTWAIT);
if (m == 0)
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);
len += sizeof(struct ipx);
}
ipx->ipx_len = htons((u_short)len);
@ -262,7 +263,7 @@ ipx_output(ipxp, m0)
*/
so = ipxp->ipxp_socket;
if (so->so_options & SO_DONTROUTE)
return (ipx_outputfl(m, (struct route *)0,
return (ipx_outputfl(m, (struct route *)NULL,
(so->so_options & SO_BROADCAST) | IPX_ROUTETOIF));
/*
* Use cached route for previous datagram if
@ -279,7 +280,7 @@ ipx_output(ipxp, m0)
/*
* I think that this will all be handled in ipx_pcbconnect!
*/
if (ro->ro_rt) {
if (ro->ro_rt != NULL) {
if(ipx_neteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) {
/*
* This assumes we have no GH type routes
@ -301,17 +302,14 @@ ipx_output(ipxp, m0)
} else {
re_route:
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)0;
ro->ro_rt = NULL;
}
}
ipxp->ipxp_lastdst = ipx->ipx_dna;
#endif /* ancient_history */
if (noipxRoute)
ro = 0;
return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST));
}
/* ARGSUSED */
int
ipx_ctloutput(req, so, level, name, value, p)
int req, level;
@ -323,7 +321,6 @@ ipx_ctloutput(req, so, level, name, value, p)
register struct mbuf *m;
struct ipxpcb *ipxp = sotoipxpcb(so);
int mask, error = 0;
/*extern long ipx_pexseq;*/ /*XXX*//*JRE*/
if (ipxp == NULL)
return (EINVAL);
@ -331,10 +328,10 @@ ipx_ctloutput(req, so, level, name, value, p)
switch (req) {
case PRCO_GETOPT:
if (value==NULL)
if (value == NULL)
return (EINVAL);
m = m_get(M_DONTWAIT, MT_DATA);
if (m==NULL)
if (m == NULL)
return (ENOBUFS);
switch (name) {
@ -550,7 +547,7 @@ ipx_send(so, flags, m, nam, control, p)
struct ipx_addr laddr;
int s = 0;
if (nam) {
if (nam != NULL) {
laddr = ipxp->ipxp_laddr;
if (!ipx_nullhost(ipxp->ipxp_faddr)) {
error = EISCONN;
@ -573,7 +570,7 @@ ipx_send(so, flags, m, nam, control, p)
}
error = ipx_output(ipxp, m);
m = NULL;
if (nam) {
if (nam != NULL) {
ipx_pcbdisconnect(ipxp);
splx(s);
ipxp->ipxp_laddr.x_host = laddr.x_host;
@ -615,7 +612,7 @@ ripx_attach(so, proto, p)
int s;
struct ipxpcb *ipxp = sotoipxpcb(so);
if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
if (p != NULL && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
s = splnet();
error = ipx_pcballoc(so, &ipxrawpcb, p);

View File

@ -33,7 +33,7 @@
*
* @(#)ipx_var.h
*
* $Id$
* $Id: ipx_var.h,v 1.5 1997/02/22 09:41:58 peter Exp $
*/
#ifndef _NETIPX_IPX_VAR_H_
@ -43,15 +43,51 @@
* IPX Kernel Structures and Variables
*/
struct ipxstat {
int ipxs_badsum; /* checksum bad */
int ipxs_tooshort; /* packet too short */
int ipxs_toosmall; /* not enough data */
int ipxs_badhlen; /* ip header length < data size */
int ipxs_badlen; /* ip length < ip header length */
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
extern int ipxcksum;
extern long ipx_pexseq;
extern struct ipxstat ipxstat;
#endif
extern struct ipxpcb ipxrawpcb;
extern struct pr_usrreqs ipx_usrreqs;
extern struct pr_usrreqs ripx_usrreqs;
extern struct sockaddr_ipx ipx_netmask;
extern struct sockaddr_ipx ipx_hostmask;
#endif
extern union ipx_net ipx_zeronet;
extern union ipx_host ipx_zerohost;
extern union ipx_net ipx_broadnet;
extern union ipx_host ipx_broadhost;
void ipx_abort __P((struct ipxpcb *ipxp));
u_short ipx_cksum __P((struct mbuf *m, int len));
int ipx_control __P((struct socket *so, int cmd, caddr_t data,
struct ifnet *ifp, struct proc *p));
void ipx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy));
int ipx_ctloutput __P((int req, struct socket *so, int level, int name,
struct mbuf **value, struct proc *p));
void ipx_drop __P((struct ipxpcb *ipxp, int errno));
void ipx_init __P((void));
void ipx_input __P((struct mbuf *m, struct ipxpcb *ipxp));
void ipxintr __P((void));
int ipx_outputfl __P((struct mbuf *m0, struct route *ro, int flags));
int ipx_output_type20(struct mbuf *);
int ipx_peeraddr __P((struct socket *so, struct mbuf *nam));
int ipx_sockaddr __P((struct socket *so, struct mbuf *nam));
void ipx_watch_output __P((struct mbuf *m, struct ifnet *ifp));
#endif /* KERNEL */
#endif /* _NETIPX_IPX_VAR_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)spx.h
*
* $Id: spx.h,v 1.10 1997/04/05 20:05:10 jhay Exp $
* $Id: spx.h,v 1.11 1997/05/01 06:21:30 jhay Exp $
*/
#ifndef _NETIPX_SPX_H_
@ -168,34 +168,17 @@ struct spxpcb {
#define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so)))
#ifdef KERNEL
extern struct pr_usrreqs spx_usrreqs;
extern struct pr_usrreqs spx_usrreq_sps;
void spx_abort __P((struct ipxpcb *ipxp));
struct spxpcb *
spx_close __P((struct spxpcb *cb));
void spx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy));
int spx_ctloutput __P((int req, struct socket *so, int level, int name,
struct mbuf **value, struct proc *p));
struct spxpcb *
spx_disconnect __P((struct spxpcb *cb));
struct spxpcb *
spx_drop __P((struct spxpcb *cb, int errno));
void spx_fasttimo __P((void));
void spx_init __P((void));
void spx_input __P((struct mbuf *m, struct ipxpcb *ipxp));
int spx_output __P((struct spxpcb *cb, struct mbuf *m0));
void spx_quench __P((struct ipxpcb *ipxp));
int spx_reass __P((struct spxpcb *cb, struct spx *si));
void spx_setpersist __P((struct spxpcb *cb));
void spx_slowtimo __P((void));
void spx_template __P((struct spxpcb *cb));
struct spxpcb *
spx_timers __P((struct spxpcb *cb, int timer));
struct spxpcb *
spx_usrclosed __P((struct spxpcb *cb));
#endif /* KERNEL */
#endif /* !_NETIPX_SPX_H_ */
#endif /* _NETIPX_SPX_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)spx_debug.c
*
* $Id$
* $Id: spx_debug.c,v 1.8 1997/02/22 09:41:58 peter Exp $
*/
#include <sys/param.h>
@ -63,9 +63,9 @@
#include <netipx/spx_debug.h>
#ifdef TCPDEBUG
static int spxconsdebug = 0;
static struct spx_debug spx_debug[SPX_NDEBUG];
static int spx_debx;
static int spxconsdebug = 0;
static struct spx_debug spx_debug[SPX_NDEBUG];
static int spx_debx;
#endif
/*
@ -91,20 +91,22 @@ spx_trace(act, ostate, sp, si, req)
sd->sd_act = act;
sd->sd_ostate = ostate;
sd->sd_cb = (caddr_t)sp;
if (sp)
if (sp != NULL)
sd->sd_sp = *sp;
else
bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
if (si)
bzero((caddr_t)&sd->sd_sp, sizeof(*sp));
if (si != NULL)
sd->sd_si = *si;
else
bzero((caddr_t)&sd->sd_si, sizeof (*si));
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)
if (ostate >= TCP_NSTATES)
ostate = 0;
if (act >= SA_DROP)
act = SA_DROP;
if (sp != NULL)
printf("%x %s:", sp, tcpstates[ostate]);
else
printf("???????? ");
@ -115,7 +117,7 @@ spx_trace(act, ostate, sp, si, req)
case SA_INPUT:
case SA_OUTPUT:
case SA_DROP:
if (si == 0)
if (si == NULL)
break;
seq = si->si_seq;
ack = si->si_ack;
@ -149,7 +151,7 @@ spx_trace(act, ostate, sp, si, req)
ipx_printhost(&si->si_sna);
ipx_printhost(&si->si_dna);
if (act==SA_RESPOND) {
if (act == SA_RESPOND) {
printf("ipx_len = %x, ",
((struct ipx *)si)->ipx_len);
}

View File

@ -33,7 +33,7 @@
*
* @(#)spx_debug.h
*
* $Id$
* $Id: spx_debug.h,v 1.8 1997/02/22 09:41:59 peter Exp $
*/
#ifndef _NETIPX_SPX_DEBUG_H_
@ -74,6 +74,6 @@ extern char *tcpstates[];
void spx_trace __P((int act, int ostate, struct spxpcb *sp, struct spx *si,
int req));
#endif
#endif /* KERNEL */
#endif /* !_NETIPX_SPX_DEBUG_H_ */
#endif /* _NETIPX_SPX_DEBUG_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)spx_timer.h
*
* $Id$
* $Id: spx_timer.h,v 1.7 1997/02/22 09:41:59 peter Exp $
*/
#ifndef _NETIPX_SPX_TIMER_H_
@ -121,8 +121,4 @@ char *spxtimers[] =
(tv) = (tvmax); \
}
#ifdef KERNEL
extern int spx_backoff[];
#endif
#endif
#endif /* _NETIPX_SPX_TIMER_H_ */

View File

@ -33,7 +33,7 @@
*
* @(#)spx_usrreq.h
*
* $Id: spx_usrreq.c,v 1.11 1997/04/05 20:05:11 jhay Exp $
* $Id: spx_usrreq.c,v 1.12 1997/05/01 06:21:31 jhay Exp $
*/
#include <sys/param.h>
@ -63,15 +63,33 @@
/*
* SPX protocol implementation.
*/
struct spx spx_savesi;
int traceallspxs = 0;
int spx_hardnosed;
int spx_use_delack = 0;
u_short spx_newchecks[50];
struct spx_istat spx_istat;
u_short spx_iss;
u_short spx_newchecks[50];
int spx_hardnosed;
int spx_use_delack = 0;
int traceallspxs = 0;
struct spx spx_savesi;
struct spx_istat spx_istat;
/* Following was struct spxstat spxstat; */
#ifndef spxstat
#define spxstat spx_istat.newstats
#endif
int spx_backoff[SPX_MAXRXTSHIFT+1] =
{ 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
static void spx_abort(struct ipxpcb *ipxp);
static struct spxpcb *spx_close(struct spxpcb *cb);
static struct spxpcb *spx_disconnect(struct spxpcb *cb);
static struct spxpcb *spx_drop(struct spxpcb *cb, int errno);
static int spx_output(struct spxpcb *cb, struct mbuf *m0);
static void spx_quench(struct ipxpcb *ipxp);
static int spx_reass(struct spxpcb *cb, struct spx *si);
static void spx_setpersist(struct spxpcb *cb);
static void spx_template(struct spxpcb *cb);
static struct spxpcb *spx_timers(struct spxpcb *cb, int timer);
static struct spxpcb *spx_usrclosed(struct spxpcb *cb);
static int spx_usr_abort(struct socket *so);
static int spx_accept(struct socket *so, struct mbuf *nam);
@ -93,7 +111,7 @@ struct pr_usrreqs spx_usrreqs = {
spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
ipx_sockaddr
ipx_sockaddr, sosend, soreceive, soselect
};
struct pr_usrreqs spx_usrreq_sps = {
@ -101,7 +119,7 @@ struct pr_usrreqs spx_usrreq_sps = {
spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
ipx_sockaddr
ipx_sockaddr, sosend, soreceive, soselect
};
void
@ -111,7 +129,6 @@ spx_init()
spx_iss = 1; /* WRONG !! should fish it out of TODR */
}
/*ARGSUSED*/
void
spx_input(m, ipxp)
register struct mbuf *m;
@ -124,16 +141,17 @@ spx_input(m, ipxp)
short ostate = 0;
spxstat.spxs_rcvtotal++;
if (ipxp == 0) {
if (ipxp == NULL) {
panic("No ipxpcb in spx_input\n");
return;
}
cb = ipxtospxpcb(ipxp);
if (cb == 0) goto bad;
if (cb == NULL)
goto bad;
if (m->m_len < sizeof(*si)) {
if ((m = m_pullup(m, sizeof(*si))) == 0) {
if ((m = m_pullup(m, sizeof(*si))) == NULL) {
spxstat.spxs_rcvshort++;
return;
}
@ -153,7 +171,7 @@ spx_input(m, ipxp)
struct spxpcb *ocb = cb;
so = sonewconn(so, 0);
if (so == 0) {
if (so == NULL) {
goto drop;
}
/*
@ -203,7 +221,7 @@ spx_input(m, ipxp)
am = m_get(M_DONTWAIT, MT_SONAME);
if (am == NULL)
goto drop;
am->m_len = sizeof (struct sockaddr_ipx);
am->m_len = sizeof(struct sockaddr_ipx);
sipx = mtod(am, struct sockaddr_ipx *);
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
@ -213,11 +231,11 @@ spx_input(m, ipxp)
ipxp->ipxp_laddr = si->si_dna;
if (ipx_pcbconnect(ipxp, am, &proc0)) {
ipxp->ipxp_laddr = laddr;
(void) m_free(am);
m_free(am);
spx_istat.noconn++;
goto drop;
}
(void) m_free(am);
m_free(am);
spx_template(cb);
dropsocket = 0; /* committed to socket */
cb->s_did = si->si_sid;
@ -238,7 +256,7 @@ spx_input(m, ipxp)
* implementation.
*/
case TCPS_SYN_RECEIVED: {
if (si->si_did!=cb->s_sid) {
if (si->si_did != cb->s_sid) {
spx_istat.wrncon++;
goto drop;
}
@ -262,7 +280,7 @@ spx_input(m, ipxp)
* connection id.
*/
case TCPS_SYN_SENT:
if (si->si_did!=cb->s_sid) {
if (si->si_did != cb->s_sid) {
spx_istat.notme++;
goto drop;
}
@ -288,25 +306,29 @@ spx_input(m, ipxp)
if (so->so_options & SO_DEBUG || traceallspxs)
spx_trace(SA_INPUT, (u_char)ostate, cb, &spx_savesi, 0);
m->m_len -= sizeof (struct ipx);
m->m_pkthdr.len -= sizeof (struct ipx);
m->m_data += sizeof (struct ipx);
m->m_len -= sizeof(struct ipx);
m->m_pkthdr.len -= sizeof(struct ipx);
m->m_data += sizeof(struct ipx);
if (spx_reass(cb, si)) {
(void) m_freem(m);
m_freem(m);
}
if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
(void) spx_output(cb, (struct mbuf *)0);
spx_output(cb, (struct mbuf *)NULL);
cb->s_flags &= ~(SF_WIN|SF_RXT);
return;
dropwithreset:
if (dropsocket)
(void) soabort(so);
soabort(so);
si->si_seq = ntohs(si->si_seq);
si->si_ack = ntohs(si->si_ack);
si->si_alo = ntohs(si->si_alo);
#ifdef IPXERRORMSGS
ipx_error(dtom(si), IPX_ERR_NOSOCK, 0);
#else
m_freem(dtom(si));
#endif
if (cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || traceallspxs)
spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
return;
@ -326,7 +348,7 @@ int spxrexmtthresh = 3;
* but its function is somewhat different: It merely queues
* packets up, and suppresses duplicates.
*/
int
static int
spx_reass(cb, si)
register struct spxpcb *cb;
register struct spx *si;
@ -366,7 +388,7 @@ register struct spx *si;
cb->s_snxt = si->si_ack;
cb->s_cwnd = CUNIT;
cb->s_force = 1 + SPXT_REXMT;
(void) spx_output(cb, (struct mbuf *)0);
spx_output(cb, (struct mbuf *)NULL);
cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
cb->s_rtt = 0;
if (cwnd >= 4 * CUNIT)
@ -484,18 +506,26 @@ register struct spx *si;
spxstat.spxs_rcvpackafterwin++;
if (si->si_cc & SPX_OB) {
if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) {
#ifdef IPXERRORMSGS
ipx_error(dtom(si), IPX_ERR_FULLUP, 0);
#else
m_freem(dtom(si));
#endif
return (0);
} /* else queue this packet; */
} else {
/*register struct socket *so = cb->s_ipxpcb->ipxp_socket;
if (so->so_state && SS_NOFDREF) {
ipx_error(dtom(si), IPX_ERR_NOSOCK, 0);
(void)spx_close(cb);
spx_close(cb);
} else
would crash system*/
spx_istat.notyet++;
#ifdef IPXERRORMSGS
ipx_error(dtom(si), IPX_ERR_FULLUP, 0);
#else
m_freem(dtom(si));
#endif
return (0);
}
}
@ -520,7 +550,7 @@ register struct spx *si;
* Loop through all packets queued up to insert in
* appropriate sequence.
*/
for (q = cb->s_q.si_next; q!=&cb->s_q; q = q->si_next) {
for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
if (si->si_seq == SI(q)->si_seq) {
spxstat.spxs_rcvduppack++;
return (1);
@ -546,7 +576,7 @@ register struct spx *si;
* number, and present all acknowledged data to user;
* If in packet interface mode, show packet headers.
*/
for (q = cb->s_q.si_next; q!=&cb->s_q; q = q->si_next) {
for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
if (SI(q)->si_seq == cb->s_ack) {
cb->s_ack++;
m = dtom(q);
@ -611,7 +641,8 @@ register struct spx *si;
} else
break;
}
if (wakeup) sorwakeup(so);
if (wakeup)
sorwakeup(so);
return (0);
}
@ -623,14 +654,19 @@ spx_ctlinput(cmd, arg_as_sa, dummy)
{
caddr_t arg = (/* XXX */ caddr_t)arg_as_sa;
struct ipx_addr *na;
struct ipx_errp *errp = (struct ipx_errp *)arg;
struct ipxpcb *ipxp;
struct sockaddr_ipx *sipx;
#ifdef IPXERRORMSGS
struct ipxpcb *ipxp;
struct ipx_errp *errp = (struct ipx_errp *)arg;
int type;
#endif
if (cmd < 0 || cmd > PRC_NCMDS)
return;
#ifdef IPXERRORMSGS
type = IPX_ERR_UNREACH_HOST;
#endif
switch (cmd) {
@ -647,12 +683,15 @@ spx_ctlinput(cmd, arg_as_sa, dummy)
break;
default:
#ifdef IPXERRORMSGS
errp = (struct ipx_errp *)arg;
na = &errp->ipx_err_ipx.ipx_dna;
type = errp->ipx_err_num;
type = ntohs((u_short)type);
#endif
break;
}
#ifdef IPXERRORMSGS
switch (type) {
case IPX_ERR_UNREACH_HOST:
@ -663,12 +702,12 @@ spx_ctlinput(cmd, arg_as_sa, dummy)
case IPX_ERR_NOSOCK:
ipxp = ipx_pcblookup(na, errp->ipx_err_ipx.ipx_sna.x_port,
IPX_WILDCARD);
if (ipxp) {
if(ipxp->ipxp_pcb)
(void) spx_drop((struct spxpcb *)ipxp->ipxp_pcb,
if (ipxp != NULL) {
if(ipxp->ipxp_pcb != NULL)
spx_drop((struct spxpcb *)ipxp->ipxp_pcb,
(int)ipxctlerrmap[cmd]);
else
(void) ipx_drop(ipxp, (int)ipxctlerrmap[cmd]);
ipx_drop(ipxp, (int)ipxctlerrmap[cmd]);
}
break;
@ -676,18 +715,19 @@ spx_ctlinput(cmd, arg_as_sa, dummy)
ipx_pcbnotify(na, 0, spx_quench, (long)0);
break;
}
#endif
}
/*
* When a source quench is received, close congestion window
* to one packet. We will gradually open it again as we proceed.
*/
void
static void
spx_quench(ipxp)
struct ipxpcb *ipxp;
{
struct spxpcb *cb = ipxtospxpcb(ipxp);
if (cb)
if (cb != NULL)
cb->s_cwnd = CUNIT;
}
@ -704,7 +744,7 @@ register struct ipxpcb *ipxp;
int badseq, len;
struct mbuf *firstbad, *m0;
if (cb) {
if (cb != NULL) {
/*
* The notification that we have sent
* too much is bad news -- we will
@ -721,16 +761,17 @@ register struct ipxpcb *ipxp;
sb = &ipxp->ipxp_socket->so_snd;
cb->s_mtu = ep->ipx_err_param;
badseq = SI(&ep->ipx_err_ipx)->si_seq;
for (m = sb->sb_mb; m; m = m->m_act) {
for (m = sb->sb_mb; m != NULL; m = m->m_act) {
si = mtod(m, struct spx *);
if (si->si_seq == badseq)
break;
}
if (m == 0) return;
if (m == NULL)
return;
firstbad = m;
/*for (;;) {*/
/* calculate length */
for (m0 = m, len = 0; m ; m = m->m_next)
for (m0 = m, len = 0; m != NULL; m = m->m_next)
len += m->m_len;
if (len > cb->s_mtu) {
}
@ -740,14 +781,14 @@ register struct ipxpcb *ipxp;
}
#endif
int
static int
spx_output(cb, m0)
register struct spxpcb *cb;
struct mbuf *m0;
{
struct socket *so = cb->s_ipxpcb->ipxp_socket;
register struct mbuf *m;
register struct spx *si = (struct spx *) 0;
register struct spx *si = (struct spx *)NULL;
register struct sockbuf *sb = &so->so_snd;
int len = 0, win, rcv_win;
short span, off, recordp = 0;
@ -758,20 +799,20 @@ spx_output(cb, m0)
#endif
struct mbuf *mprev;
if (m0) {
if (m0 != NULL) {
int mtu = cb->s_mtu;
int datalen;
/*
* Make sure that packet isn't too big.
*/
for (m = m0; m ; m = m->m_next) {
for (m = m0; m != NULL; m = m->m_next) {
mprev = m;
len += m->m_len;
if (m->m_flags & M_EOR)
recordp = 1;
}
datalen = (cb->s_flags & SF_HO) ?
len - sizeof (struct spxhdr) : len;
len - sizeof(struct spxhdr) : len;
if (datalen > mtu) {
if (cb->s_flags & SF_PI) {
m_freem(m0);
@ -790,7 +831,7 @@ spx_output(cb, m0)
if (cb->s_flags & SF_NEWCALL) {
struct mbuf *mm = m;
spx_newchecks[7]++;
while (mm) {
while (mm != NULL) {
mm->m_flags &= ~M_EOR;
mm = mm->m_next;
}
@ -799,7 +840,7 @@ spx_output(cb, m0)
if (error) {
cb->s_cc |= oldEM;
m_freem(m0);
return(error);
return (error);
}
m_adj(m0, mtu);
len -= mtu;
@ -818,7 +859,7 @@ spx_output(cb, m0)
else {
struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
if (m1 == 0) {
if (m1 == NULL) {
m_freem(m0);
return (ENOBUFS);
}
@ -828,7 +869,7 @@ spx_output(cb, m0)
}
}
m = m_gethdr(M_DONTWAIT, MT_HEADER);
if (m == 0) {
if (m == NULL) {
m_freem(m0);
return (ENOBUFS);
}
@ -836,17 +877,17 @@ spx_output(cb, m0)
* Fill in mbuf with extended SP header
* and addresses and length put into network format.
*/
MH_ALIGN(m, sizeof (struct spx));
m->m_len = sizeof (struct spx);
MH_ALIGN(m, sizeof(struct spx));
m->m_len = sizeof(struct spx);
m->m_next = m0;
si = mtod(m, struct spx *);
si->si_i = *cb->s_ipx;
si->si_s = cb->s_shdr;
if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
register struct spxhdr *sh;
if (m0->m_len < sizeof (*sh)) {
if (m0->m_len < sizeof(*sh)) {
if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) {
(void) m_free(m);
m_free(m);
m_freem(m0);
return (EINVAL);
}
@ -855,13 +896,13 @@ spx_output(cb, m0)
sh = mtod(m0, struct spxhdr *);
si->si_dt = sh->spx_dt;
si->si_cc |= sh->spx_cc & SPX_EM;
m0->m_len -= sizeof (*sh);
m0->m_data += sizeof (*sh);
len -= sizeof (*sh);
m0->m_len -= sizeof(*sh);
m0->m_data += sizeof(*sh);
len -= sizeof(*sh);
}
len += sizeof(*si);
if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
si->si_cc |= SPX_EM;
si->si_cc |= SPX_EM;
spx_newchecks[8]++;
}
if (cb->s_oobflags & SF_SOOB) {
@ -892,7 +933,7 @@ spx_output(cb, m0)
again:
sendalot = 0;
off = cb->s_snxt - cb->s_rack;
win = min(cb->s_swnd, (cb->s_cwnd/CUNIT));
win = min(cb->s_swnd, (cb->s_cwnd / CUNIT));
/*
* If in persist timeout with window of 0, send a probe.
@ -996,13 +1037,13 @@ spx_output(cb, m0)
si = 0;
if (len > 0) {
cb->s_want = cb->s_snxt;
for (m = sb->sb_mb; m; m = m->m_act) {
for (m = sb->sb_mb; m != NULL; m = m->m_act) {
si = mtod(m, struct spx *);
if (SSEQ_LEQ(cb->s_snxt, si->si_seq))
break;
}
found:
if (si) {
if (si != NULL) {
if (si->si_seq == cb->s_snxt)
cb->s_snxt++;
else
@ -1018,7 +1059,7 @@ spx_output(cb, m0)
if (SSEQ_LT(alo, cb->s_alo))
alo = cb->s_alo;
if (si) {
if (si != NULL) {
/*
* must make a copy of this packet for
* ipx_output to monkey with
@ -1041,20 +1082,20 @@ spx_output(cb, m0)
if (cb->s_flags & SF_ACKNOW)
spxstat.spxs_sndacks++;
m = m_gethdr(M_DONTWAIT, MT_HEADER);
if (m == 0)
if (m == NULL)
return (ENOBUFS);
/*
* Fill in mbuf with extended SP header
* and addresses and length put into network format.
*/
MH_ALIGN(m, sizeof (struct spx));
m->m_len = sizeof (*si);
m->m_pkthdr.len = sizeof (*si);
MH_ALIGN(m, sizeof(struct spx));
m->m_len = sizeof(*si);
m->m_pkthdr.len = sizeof(*si);
si = mtod(m, struct spx *);
si->si_i = *cb->s_ipx;
si->si_s = cb->s_shdr;
si->si_seq = cb->s_smax + 1;
si->si_len = htons(sizeof (*si));
si->si_len = htons(sizeof(*si));
si->si_cc |= SPX_SP;
} else {
cb->s_outx = 3;
@ -1129,7 +1170,7 @@ spx_output(cb, m0)
spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
if (so->so_options & SO_DONTROUTE)
error = ipx_outputfl(m, (struct route *)0, IPX_ROUTETOIF);
error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF);
else
error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0);
}
@ -1155,7 +1196,7 @@ spx_output(cb, m0)
int spx_do_persist_panics = 0;
void
static void
spx_setpersist(cb)
register struct spxpcb *cb;
{
@ -1172,7 +1213,7 @@ spx_setpersist(cb)
if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
cb->s_rxtshift++;
}
/*ARGSUSED*/
int
spx_ctloutput(req, so, level, name, value, p)
int req;
@ -1332,7 +1373,7 @@ spx_accept(so, nam)
ipxp = sotoipxpcb(so);
sipx = mtod(nam, struct sockaddr_ipx *);
nam->m_len = sizeof (struct sockaddr_ipx);
nam->m_len = sizeof(struct sockaddr_ipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_faddr;
return (0);
@ -1387,11 +1428,10 @@ spx_attach(so, proto, p)
cb->s_swl1 = -1;
cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q;
cb->s_ipxpcb = ipxp;
cb->s_mtu = 576 - sizeof (struct spx);
cb->s_mtu = 576 - sizeof(struct spx);
cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
cb->s_ssthresh = cb->s_cwnd;
cb->s_cwmx = sbspace(sb) * CUNIT /
(2 * sizeof (struct spx));
cb->s_cwmx = sbspace(sb) * CUNIT / (2 * sizeof(struct spx));
/* Above is recomputed when connecting to account
for changed buffering or mtu's */
cb->s_rtt = SPXTV_SRTTBASE;
@ -1399,7 +1439,7 @@ spx_attach(so, proto, p)
SPXT_RANGESET(cb->s_rxtcur,
((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1,
SPXTV_MIN, SPXTV_REXMTMAX);
ipxp->ipxp_pcb = (caddr_t) cb;
ipxp->ipxp_pcb = (caddr_t)cb;
spx_attach_end:
splx(s);
return (error);
@ -1440,7 +1480,7 @@ spx_connect(so, nam, p)
s = splnet();
if (ipxp->ipxp_lport == 0) {
error = ipx_pcbbind(ipxp, (struct mbuf *)0, p);
error = ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
if (error)
goto spx_connect_end;
}
@ -1463,7 +1503,7 @@ spx_connect(so, nam, p)
* cb->s_dport.
*/
ipxp->ipxp_fport = 0;
error = spx_output(cb, (struct mbuf *) 0);
error = spx_output(cb, (struct mbuf *)NULL);
spx_connect_end:
splx(s);
return (error);
@ -1527,7 +1567,7 @@ spx_listen(so, p)
cb = ipxtospxpcb(ipxp);
if (ipxp->ipxp_lport == 0)
error = ipx_pcbbind(ipxp, (struct mbuf *)0, p);
error = ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
if (error == 0)
cb->s_state = TCPS_LISTEN;
return (error);
@ -1551,7 +1591,7 @@ spx_rcvd(so, flags)
s = splnet();
cb->s_flags |= SF_RVD;
spx_output(cb, (struct mbuf *) 0);
spx_output(cb, (struct mbuf *)NULL);
cb->s_flags &= ~SF_RVD;
splx(s);
return (0);
@ -1604,10 +1644,10 @@ spx_send(so, flags, m, addr, controlp, p)
}
cb->s_oobflags |= SF_SOOB;
}
if (controlp) {
if (controlp != NULL) {
u_short *p = mtod(controlp, u_short *);
spx_newchecks[2]++;
if ((p[0] == 5) && p[1] == 1) { /* XXXX, for testing */
if ((p[0] == 5) && (p[1] == 1)) { /* XXXX, for testing */
cb->s_shdr.spx_dt = *(u_char *)(&p[2]);
spx_newchecks[3]++;
}
@ -1641,8 +1681,8 @@ spx_shutdown(so)
s = splnet();
socantsendmore(so);
cb = spx_usrclosed(cb);
if (cb)
error = spx_output(cb, (struct mbuf *) 0);
if (cb != NULL)
error = spx_output(cb, (struct mbuf *)NULL);
splx(s);
return (error);
}
@ -1655,7 +1695,6 @@ spx_sp_attach(so, proto, p)
{
int error;
struct ipxpcb *ipxp;
struct spxpcb *cb;
error = spx_attach(so, proto, p);
if (error == 0) {
@ -1672,7 +1711,7 @@ spx_sp_attach(so, proto, p)
* in a skeletal spx header (choosing connection id),
* minimizing the amount of work necessary when the connection is used.
*/
void
static void
spx_template(cb)
register struct spxpcb *cb;
{
@ -1700,7 +1739,7 @@ spx_template(cb)
* discard ipx protocol control block
* wake up any sleepers
*/
struct spxpcb *
static struct spxpcb *
spx_close(cb)
register struct spxpcb *cb;
{
@ -1716,36 +1755,39 @@ spx_close(cb)
remque(s->si_prev);
m_freem(m);
}
(void) m_free(dtom(cb->s_ipx));
(void) m_free(dtom(cb));
m_free(dtom(cb->s_ipx));
m_free(dtom(cb));
ipxp->ipxp_pcb = 0;
soisdisconnected(so);
ipx_pcbdetach(ipxp);
spxstat.spxs_closed++;
return ((struct spxpcb *)0);
return ((struct spxpcb *)NULL);
}
/*
* Someday we may do level 3 handshaking
* to close a connection or send a xerox style error.
* For now, just close.
*/
struct spxpcb *
static struct spxpcb *
spx_usrclosed(cb)
register struct spxpcb *cb;
{
return (spx_close(cb));
}
struct spxpcb *
static struct spxpcb *
spx_disconnect(cb)
register struct spxpcb *cb;
{
return (spx_close(cb));
}
/*
* Drop connection, reporting
* the specified error.
*/
struct spxpcb *
static struct spxpcb *
spx_drop(cb, errno)
register struct spxpcb *cb;
int errno;
@ -1760,23 +1802,21 @@ spx_drop(cb, errno)
if (TCPS_HAVERCVDSYN(cb->s_state)) {
spxstat.spxs_drops++;
cb->s_state = TCPS_CLOSED;
/*(void) tcp_output(cb);*/
/*tcp_output(cb);*/
} else
spxstat.spxs_conndrops++;
so->so_error = errno;
return (spx_close(cb));
}
void
static void
spx_abort(ipxp)
struct ipxpcb *ipxp;
{
(void) spx_close((struct spxpcb *)ipxp->ipxp_pcb);
spx_close((struct spxpcb *)ipxp->ipxp_pcb);
}
int spx_backoff[SPX_MAXRXTSHIFT+1] =
{ 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
/*
* Fast timeout routine for processing delayed acks
*/
@ -1788,14 +1828,14 @@ spx_fasttimo()
int s = splnet();
ipxp = ipxpcb.ipxp_next;
if (ipxp)
if (ipxp != NULL)
for (; ipxp != &ipxpcb; ipxp = ipxp->ipxp_next)
if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) &&
if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL &&
(cb->s_flags & SF_DELACK)) {
cb->s_flags &= ~SF_DELACK;
cb->s_flags |= SF_ACKNOW;
spxstat.spxs_delack++;
(void) spx_output(cb, (struct mbuf *) 0);
spx_output(cb, (struct mbuf *)NULL);
}
splx(s);
}
@ -1817,14 +1857,14 @@ spx_slowtimo()
* Search through tcb's and update active timers.
*/
ip = ipxpcb.ipxp_next;
if (ip == 0) {
if (ip == NULL) {
splx(s);
return;
}
while (ip != &ipxpcb) {
cb = ipxtospxpcb(ip);
ipnxt = ip->ipxp_next;
if (cb == 0)
if (cb == NULL)
goto tpgone;
for (i = 0; i < SPXT_NTIMERS; i++) {
if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
@ -1842,10 +1882,11 @@ spx_slowtimo()
spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
splx(s);
}
/*
* SPX timer processing.
*/
struct spxpcb *
static struct spxpcb *
spx_timers(cb, timer)
register struct spxpcb *cb;
int timer;
@ -1907,7 +1948,7 @@ spx_timers(cb, timer)
win = 2;
cb->s_cwnd = CUNIT;
cb->s_ssthresh = win * CUNIT;
(void) spx_output(cb, (struct mbuf *) 0);
spx_output(cb, (struct mbuf *)NULL);
break;
/*
@ -1917,7 +1958,7 @@ spx_timers(cb, timer)
case SPXT_PERSIST:
spxstat.spxs_persisttimeo++;
spx_setpersist(cb);
(void) spx_output(cb, (struct mbuf *) 0);
spx_output(cb, (struct mbuf *)NULL);
break;
/*
@ -1932,7 +1973,7 @@ spx_timers(cb, timer)
if (cb->s_idle >= SPXTV_MAXIDLE)
goto dropit;
spxstat.spxs_keepprobe++;
(void) spx_output(cb, (struct mbuf *) 0);
spx_output(cb, (struct mbuf *)NULL);
} else
cb->s_idle = 0;
cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;

View File

@ -33,7 +33,7 @@
*
* @(#)spx_var.h
*
* $Id$
* $Id: spx_var.h,v 1.6 1997/02/22 09:42:00 peter Exp $
*/
#ifndef _NETIPX_SPX_VAR_H_
@ -107,17 +107,6 @@ struct spx_istat {
struct spxstat newstats;
};
#ifdef KERNEL
extern struct spx_istat spx_istat;
extern u_short spx_iss;
/* Following was struct spxstat spxstat; */
#ifndef spxstat
#define spxstat spx_istat.newstats
#endif
#endif
#define SPX_ISSINCR 128
/*
* spx sequence numbers are 16 bit integers operated
@ -129,4 +118,4 @@ extern u_short spx_iss;
#define SSEQ_GT(a,b) (((short)((a)-(b))) > 0)
#define SSEQ_GEQ(a,b) (((short)((a)-(b))) >= 0)
#endif
#endif /* _NETIPX_SPX_VAR_H_ */