Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _NET_INET_IPX_H_ |
| 2 | #define _NET_INET_IPX_H_ |
| 3 | /* |
| 4 | * The following information is in its entirety obtained from: |
| 5 | * |
| 6 | * Novell 'IPX Router Specification' Version 1.10 |
| 7 | * Part No. 107-000029-001 |
| 8 | * |
| 9 | * Which is available from ftp.novell.com |
| 10 | */ |
| 11 | |
| 12 | #include <linux/netdevice.h> |
| 13 | #include <net/datalink.h> |
| 14 | #include <linux/ipx.h> |
| 15 | #include <linux/list.h> |
| 16 | |
| 17 | struct ipx_address { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 18 | __be32 net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | __u8 node[IPX_NODE_LEN]; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 20 | __be16 sock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | #define ipx_broadcast_node "\377\377\377\377\377\377" |
| 24 | #define ipx_this_node "\0\0\0\0\0\0" |
| 25 | |
| 26 | #define IPX_MAX_PPROP_HOPS 8 |
| 27 | |
| 28 | struct ipxhdr { |
Al Viro | 02e6037 | 2006-11-03 00:28:23 -0800 | [diff] [blame] | 29 | __be16 ipx_checksum __attribute__ ((packed)); |
| 30 | #define IPX_NO_CHECKSUM __constant_htons(0xFFFF) |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 31 | __be16 ipx_pktsize __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | __u8 ipx_tctrl; |
| 33 | __u8 ipx_type; |
| 34 | #define IPX_TYPE_UNKNOWN 0x00 |
| 35 | #define IPX_TYPE_RIP 0x01 /* may also be 0 */ |
| 36 | #define IPX_TYPE_SAP 0x04 /* may also be 0 */ |
| 37 | #define IPX_TYPE_SPX 0x05 /* SPX protocol */ |
| 38 | #define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */ |
| 39 | #define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */ |
| 40 | struct ipx_address ipx_dest __attribute__ ((packed)); |
| 41 | struct ipx_address ipx_source __attribute__ ((packed)); |
| 42 | }; |
| 43 | |
| 44 | static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb) |
| 45 | { |
Arnaldo Carvalho de Melo | 9c70220 | 2007-04-25 18:04:18 -0700 | [diff] [blame^] | 46 | return (struct ipxhdr *)skb_transport_header(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | struct ipx_interface { |
| 50 | /* IPX address */ |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 51 | __be32 if_netnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | unsigned char if_node[IPX_NODE_LEN]; |
| 53 | atomic_t refcnt; |
| 54 | |
| 55 | /* physical device info */ |
| 56 | struct net_device *if_dev; |
| 57 | struct datalink_proto *if_dlink; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 58 | __be16 if_dlink_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /* socket support */ |
| 61 | unsigned short if_sknum; |
| 62 | struct hlist_head if_sklist; |
| 63 | spinlock_t if_sklist_lock; |
| 64 | |
| 65 | /* administrative overhead */ |
| 66 | int if_ipx_offset; |
| 67 | unsigned char if_internal; |
| 68 | unsigned char if_primary; |
| 69 | |
| 70 | struct list_head node; /* node in ipx_interfaces list */ |
| 71 | }; |
| 72 | |
| 73 | struct ipx_route { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 74 | __be32 ir_net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | struct ipx_interface *ir_intrfc; |
| 76 | unsigned char ir_routed; |
| 77 | unsigned char ir_router_node[IPX_NODE_LEN]; |
| 78 | struct list_head node; /* node in ipx_routes list */ |
| 79 | atomic_t refcnt; |
| 80 | }; |
| 81 | |
| 82 | #ifdef __KERNEL__ |
| 83 | struct ipx_cb { |
| 84 | u8 ipx_tctrl; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 85 | __be32 ipx_dest_net; |
| 86 | __be32 ipx_source_net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 88 | __be32 netnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | int index; |
| 90 | } last_hop; |
| 91 | }; |
| 92 | |
| 93 | #include <net/sock.h> |
| 94 | |
| 95 | struct ipx_sock { |
| 96 | /* struct sock has to be the first member of ipx_sock */ |
| 97 | struct sock sk; |
| 98 | struct ipx_address dest_addr; |
| 99 | struct ipx_interface *intrfc; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 100 | __be16 port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #ifdef CONFIG_IPX_INTERN |
| 102 | unsigned char node[IPX_NODE_LEN]; |
| 103 | #endif |
| 104 | unsigned short type; |
| 105 | /* |
| 106 | * To handle special ncp connection-handling sockets for mars_nwe, |
| 107 | * the connection number must be stored in the socket. |
| 108 | */ |
| 109 | unsigned short ipx_ncp_conn; |
| 110 | }; |
| 111 | |
| 112 | static inline struct ipx_sock *ipx_sk(struct sock *sk) |
| 113 | { |
| 114 | return (struct ipx_sock *)sk; |
| 115 | } |
| 116 | |
| 117 | #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) |
| 118 | #endif |
| 119 | |
| 120 | #define IPX_MIN_EPHEMERAL_SOCKET 0x4000 |
| 121 | #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff |
| 122 | |
| 123 | extern struct list_head ipx_routes; |
| 124 | extern rwlock_t ipx_routes_lock; |
| 125 | |
| 126 | extern struct list_head ipx_interfaces; |
| 127 | extern struct ipx_interface *ipx_interfaces_head(void); |
| 128 | extern spinlock_t ipx_interfaces_lock; |
| 129 | |
| 130 | extern struct ipx_interface *ipx_primary_net; |
| 131 | |
| 132 | extern int ipx_proc_init(void); |
| 133 | extern void ipx_proc_exit(void); |
| 134 | |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 135 | extern const char *ipx_frame_name(__be16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | extern const char *ipx_device_name(struct ipx_interface *intrfc); |
| 137 | |
| 138 | static __inline__ void ipxitf_hold(struct ipx_interface *intrfc) |
| 139 | { |
| 140 | atomic_inc(&intrfc->refcnt); |
| 141 | } |
| 142 | |
| 143 | extern void ipxitf_down(struct ipx_interface *intrfc); |
| 144 | |
| 145 | static __inline__ void ipxitf_put(struct ipx_interface *intrfc) |
| 146 | { |
| 147 | if (atomic_dec_and_test(&intrfc->refcnt)) |
| 148 | ipxitf_down(intrfc); |
| 149 | } |
| 150 | |
| 151 | static __inline__ void ipxrtr_hold(struct ipx_route *rt) |
| 152 | { |
| 153 | atomic_inc(&rt->refcnt); |
| 154 | } |
| 155 | |
| 156 | static __inline__ void ipxrtr_put(struct ipx_route *rt) |
| 157 | { |
| 158 | if (atomic_dec_and_test(&rt->refcnt)) |
| 159 | kfree(rt); |
| 160 | } |
| 161 | #endif /* _NET_INET_IPX_H_ */ |