diff options
author | julian <julian@FreeBSD.org> | 1995-10-26 20:31:59 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1995-10-26 20:31:59 +0000 |
commit | 90ae06d6ac1d2da3758389a70a20c91f3e9fd1dc (patch) | |
tree | d823a4d0efac391c6dfad3ac2e27c0e984cea732 /sbin/ifconfig | |
parent | 627b063e661d2c0187cf625f83db54c6aca0a0c1 (diff) | |
download | FreeBSD-src-90ae06d6ac1d2da3758389a70a20c91f3e9fd1dc.zip FreeBSD-src-90ae06d6ac1d2da3758389a70a20c91f3e9fd1dc.tar.gz |
Reviewed by: julian and jhay@mikom.csir.co.za
Submitted by: Mike Mitchell, supervisor@alb.asctmd.com
This is a bulk mport of Mike's IPX/SPX protocol stacks and all the
related gunf that goes with it..
it is not guaranteed to work 100% correctly at this time
but as we had several people trying to work on it
I figured it would be better to get it checked in so
they could all get teh same thing to work on..
Mikes been using it for a year or so
but on 2.0
more changes and stuff will be merged in from other developers now that this is in.
Mike Mitchell, Network Engineer
AMTECH Systems Corporation, Technology and Manufacturing
8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000
supervisor@alb.asctmd.com
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index cc37eb8..c0b2905 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -50,11 +50,16 @@ static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #include <netinet/in.h> #include <netinet/in_var.h> #include <arpa/inet.h> +#include <netdb.h> + +#define IPXIP +#define IPTUNNEL +#include <netipx/ipx.h> +#include <netipx/ipx_if.h> #define NSIP #include <netns/ns.h> #include <netns/ns_if.h> -#include <netdb.h> #define EON #include <netiso/iso.h> @@ -144,6 +149,7 @@ struct cmd { * Maryland principally by James O'Toole and Chris Torek. */ int in_status(), in_getaddr(); +int ipx_status(), ipx_getaddr(); int xns_status(), xns_getaddr(); int iso_status(), iso_getaddr(); int ether_status(); @@ -162,6 +168,8 @@ struct afswtch { #define C(x) ((caddr_t) &x) { "inet", AF_INET, in_status, in_getaddr, SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, + { "ipx", AF_IPX, ipx_status, ipx_getaddr, + SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, { "ns", AF_NS, xns_status, xns_getaddr, SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, { "iso", AF_ISO, iso_status, iso_getaddr, @@ -313,6 +321,16 @@ ifconfig(argc,argv,af,rafp,flag) } if (af == AF_ISO) adjust_nsellength(); + if (setipdst && af==AF_IPX) { + struct ipxip_req rq; + int size = sizeof(rq); + + rq.rq_ipx = addreq.ifra_addr; + rq.rq_ip = addreq.ifra_dstaddr; + + if (setsockopt(s, 0, SO_IPXIP_ROUTE, &rq, size) < 0) + Perror("Encapsulation Routing"); + } if (setipdst && af==AF_NS) { struct nsip_req rq; int size = sizeof(rq); @@ -539,6 +557,43 @@ in_status(force) putchar('\n'); } +ipx_status(force) + int force; +{ + struct sockaddr_ipx *sipx; + + close(s); + s = socket(AF_IPX, SOCK_DGRAM, 0); + if (s < 0) { + if (errno == EPROTONOSUPPORT) + return; + perror("ifconfig: socket"); + exit(1); + } + if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) < 0) { + if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) { + if (!force) + return; + bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); + } else + perror("ioctl (SIOCGIFADDR)"); + } + strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); + sipx = (struct sockaddr_ipx *)&ifr.ifr_addr; + printf("\tipx %s ", ipx_ntoa(sipx->sipx_addr)); + if (flags & IFF_POINTOPOINT) { /* by W. Nesheim@Cornell */ + if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) { + if (errno == EADDRNOTAVAIL) + bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); + else + Perror("ioctl (SIOCGIFDSTADDR)"); + } + strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); + sipx = (struct sockaddr_ipx *)&ifr.ifr_dstaddr; + printf("--> %s ", ipx_ntoa(sipx->sipx_addr)); + } + putchar('\n'); +} xns_status(force) int force; @@ -793,6 +848,24 @@ printb(s, v, bits) } } +#define SIPX(x) ((struct sockaddr_ipx *) &(x)) +struct sockaddr_ipx *sipxtab[] = { +SIPX(ridreq.ifr_addr), SIPX(addreq.ifra_addr), +SIPX(addreq.ifra_mask), SIPX(addreq.ifra_broadaddr)}; + +ipx_getaddr(addr, which) +char *addr; +{ + struct sockaddr_ipx *sipx = sipxtab[which]; + struct ipx_addr ipx_addr(); + + sipx->sipx_family = AF_IPX; + sipx->sipx_len = sizeof(*sipx); + sipx->sipx_addr = ipx_addr(addr); + if (which == MASK) + printf("Attempt to set IPX netmask will be ineffectual\n"); +} + #define SNS(x) ((struct sockaddr_ns *) &(x)) struct sockaddr_ns *snstab[] = { SNS(ridreq.ifr_addr), SNS(addreq.ifra_addr), |