ipx.h revision 21673
1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by the University of 17 * California, Berkeley and its contributors. 18 * 4. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)ipx.h 35 * 36 * $FreeBSD: head/sys/netipx/ipx.h 21673 1997-01-14 07:20:47Z jkh $ 37 */ 38 39#ifndef _NETIPX_IPX_H_ 40#define _NETIPX_IPX_H_ 41 42/* 43 * Constants and Structures 44 */ 45 46/* 47 * Protocols 48 */ 49#define IPXPROTO_UNKWN 0 /* Unknown */ 50#define IPXPROTO_RI 1 /* RIP Routing Information */ 51#define IPXPROTO_ECHO 2 /* Echo Protocol */ 52#define IPXPROTO_ERROR 3 /* Error Protocol */ 53#define IPXPROTO_PXP 4 /* PXP Packet Exchange */ 54#define IPXPROTO_SPX 5 /* SPX Sequenced Packet */ 55#define IPXPROTO_NCP 17 /* NCP NetWare Core */ 56#define IPXPROTO_RAW 255 /* Placemarker*/ 57#define IPXPROTO_MAX 256 /* Placemarker*/ 58 59/* 60 * Port/Socket numbers: network standard functions 61 */ 62 63#define IPXPORT_RI 1 /* NS RIP Routing Information */ 64#define IPXPORT_ECHO 2 /* NS Echo */ 65#define IPXPORT_RE 3 /* NS Router Error */ 66#define IPXPORT_FSP 0x0451 /* NW FSP File Service */ 67#define IPXPORT_SAP 0x0452 /* NW SAP Service Advertising */ 68#define IPXPORT_RIP 0x0453 /* NW RIP Routing Information */ 69#define IPXPORT_NETBIOS 0x0455 /* NW NetBIOS */ 70#define IPXPORT_DIAGS 0x0456 /* NW Diagnostics */ 71#define IPXPORT_WDOG 0x4001 /* NW Watchdog Packets */ 72#define IPXPORT_SHELL 0x4003 /* NW Shell Socket */ 73#define IPXPORT_MAX 0x8000 /* Maximum User Addressable Port */ 74 75/* flags passed to ipx_outputfl as last parameter */ 76 77#define IPX_FORWARDING 0x1 /* most of ipx header exists */ 78#define IPX_ROUTETOIF 0x10 /* same as SO_DONTROUTE */ 79#define IPX_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 80 81#define IPX_MAXHOPS 15 82 83/* flags passed to get/set socket option */ 84#define SO_HEADERS_ON_INPUT 1 85#define SO_HEADERS_ON_OUTPUT 2 86#define SO_DEFAULT_HEADERS 3 87#define SO_LAST_HEADER 4 88#define SO_IPXIP_ROUTE 5 89#define SO_SEQNO 6 90#define SO_ALL_PACKETS 7 91#define SO_MTU 8 92#define SO_IPXTUN_ROUTE 9 93 94/* 95 * IPX addressing 96 */ 97union ipx_host { 98 u_char c_host[6]; 99 u_short s_host[3]; 100}; 101 102union ipx_net { 103 u_char c_net[4]; 104 u_short s_net[2]; 105}; 106 107union ipx_net_u { 108 union ipx_net net_e; 109 u_long long_e; 110}; 111 112struct ipx_addr { 113 union ipx_net x_net; 114 union ipx_host x_host; 115 u_short x_port; 116}; 117 118/* 119 * Socket address 120 */ 121struct sockaddr_ipx { 122 u_char sipx_len; 123 u_char sipx_family; 124 struct ipx_addr sipx_addr; 125 char sipx_zero[2]; 126}; 127#define sipx_port sipx_addr.x_port 128 129/* 130 * Definitions for IPX Internet Datagram Protocol 131 */ 132struct ipx { 133 u_short ipx_sum; /* Checksum */ 134 u_short ipx_len; /* Length, in bytes, including header */ 135 u_char ipx_tc; /* Transport Control (i.e. hop count) */ 136 u_char ipx_pt; /* Packet Type (i.e. level 2 protocol) */ 137 struct ipx_addr ipx_dna; /* Destination Network Address */ 138 struct ipx_addr ipx_sna; /* Source Network Address */ 139}; 140 141#ifdef vax 142#define ipx_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */ 143#endif 144#define ipx_neteqnn(a,b) \ 145 (((a).s_net[0]==(b).s_net[0]) && ((a).s_net[1]==(b).s_net[1])) 146#define ipx_neteq(a,b) ipx_neteqnn((a).x_net, (b).x_net) 147#define satoipx_addr(sa) (((struct sockaddr_ipx *)&(sa))->sipx_addr) 148#define ipx_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \ 149 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2]) 150#define ipx_hosteq(s,t) (ipx_hosteqnh((s).x_host,(t).x_host)) 151#define ipx_nullnet(x) (((x).x_net.s_net[0]==0) && ((x).x_net.s_net[1]==0)) 152#define ipx_nullhost(x) (((x).x_host.s_host[0]==0) && \ 153 ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0)) 154#define ipx_wildnet(x) (((x).x_net.s_net[0]==0xffff) && \ 155 ((x).x_net.s_net[1]==0xffff)) 156#define ipx_wildhost(x) (((x).x_host.s_host[0]==0xffff) && \ 157 ((x).x_host.s_host[1]==0xffff) && ((x).x_host.s_host[2]==0xffff)) 158 159#ifdef KERNEL 160 161extern int ipxcksum; 162extern struct domain ipxdomain; 163extern struct sockaddr_ipx ipx_netmask; 164extern struct sockaddr_ipx ipx_hostmask; 165 166extern union ipx_host ipx_thishost; 167extern union ipx_net ipx_zeronet; 168extern union ipx_host ipx_zerohost; 169extern union ipx_net ipx_broadnet; 170extern union ipx_host ipx_broadhost; 171 172extern long ipx_pexseq; 173extern u_char ipxctlerrmap[]; 174extern struct ipxpcb ipxrawpcb; 175 176struct route; 177struct sockaddr; 178struct socket; 179void ipx_abort __P((struct ipxpcb *ipxp)); 180u_short ipx_cksum __P((struct mbuf *m, int len)); 181int ipx_control __P((struct socket *so, int cmd, caddr_t data, 182 struct ifnet *ifp)); 183void ipx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy)); 184int ipx_ctloutput __P((int req, struct socket *so, int level, int name, 185 struct mbuf **value)); 186int ipx_do_route __P((struct ipx_addr *src, struct route *ro)); 187void ipx_drop __P((struct ipxpcb *ipxp, int errno)); 188void ipx_forward __P((struct mbuf *m)); 189void ipx_init __P((void)); 190void ipx_input __P((struct mbuf *m, struct ipxpcb *ipxp)); 191void ipxintr __P((void)); 192int ipx_output __P((struct ipxpcb *ipxp, struct mbuf *m0)); 193int ipx_outputfl __P((struct mbuf *m0, struct route *ro, int flags)); 194int ipx_raw_usrreq __P((struct socket *so, int req, struct mbuf *m, 195 struct mbuf *nam, struct mbuf *control)); 196void ipx_undo_route __P((struct route *ro)); 197int ipx_usrreq __P((struct socket *so, int req, struct mbuf *m, 198 struct mbuf *nam, struct mbuf *control)); 199void ipx_watch_output __P((struct mbuf *m, struct ifnet *ifp)); 200 201#else 202 203#include <sys/cdefs.h> 204 205__BEGIN_DECLS 206struct ipx_addr 207 ipx_addr __P((const char *)); 208char *ipx_ntoa __P((struct ipx_addr)); 209__END_DECLS 210 211#endif /* KERNEL */ 212 213#endif /* !_NETIPX_IPX_H_ */ 214