| 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 | #include <linux/slab.h>
|
| 17 |
|
| 18 | struct ipx_address {
|
| 19 | __be32 net;
|
| 20 | __u8 node[IPX_NODE_LEN];
|
| 21 | __be16 sock;
|
| 22 | };
|
| 23 |
|
| 24 | #define ipx_broadcast_node "\377\377\377\377\377\377"
|
| 25 | #define ipx_this_node "\0\0\0\0\0\0"
|
| 26 |
|
| 27 | #define IPX_MAX_PPROP_HOPS 8
|
| 28 |
|
| 29 | struct ipxhdr {
|
| 30 | __be16 ipx_checksum __packed;
|
| 31 | #define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF)
|
| 32 | __be16 ipx_pktsize __packed;
|
| 33 | __u8 ipx_tctrl;
|
| 34 | __u8 ipx_type;
|
| 35 | #define IPX_TYPE_UNKNOWN 0x00
|
| 36 | #define IPX_TYPE_RIP 0x01
|
| 37 | #define IPX_TYPE_SAP 0x04
|
| 38 | #define IPX_TYPE_SPX 0x05
|
| 39 | #define IPX_TYPE_NCP 0x11
|
| 40 | #define IPX_TYPE_PPROP 0x14
|
| 41 | struct ipx_address ipx_dest __packed;
|
| 42 | struct ipx_address ipx_source __packed;
|
| 43 | };
|
| 44 |
|
| 45 |
|
| 46 | extern int sysctl_ipx_pprop_broadcasting;
|
| 47 |
|
| 48 | static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
|
| 49 | {
|
| 50 | return (struct ipxhdr *)skb_transport_header(skb);
|
| 51 | }
|
| 52 |
|
| 53 | struct ipx_interface {
|
| 54 |
|
| 55 | __be32 if_netnum;
|
| 56 | unsigned char if_node[IPX_NODE_LEN];
|
| 57 | atomic_t refcnt;
|
| 58 |
|
| 59 |
|
| 60 | struct net_device *if_dev;
|
| 61 | struct datalink_proto *if_dlink;
|
| 62 | __be16 if_dlink_type;
|
| 63 |
|
| 64 |
|
| 65 | unsigned short if_sknum;
|
| 66 | struct hlist_head if_sklist;
|
| 67 | spinlock_t if_sklist_lock;
|
| 68 |
|
| 69 |
|
| 70 | int if_ipx_offset;
|
| 71 | unsigned char if_internal;
|
| 72 | unsigned char if_primary;
|
| 73 |
|
| 74 | struct list_head node;
|
| 75 | };
|
| 76 |
|
| 77 | struct ipx_route {
|
| 78 | __be32 ir_net;
|
| 79 | struct ipx_interface *ir_intrfc;
|
| 80 | unsigned char ir_routed;
|
| 81 | unsigned char ir_router_node[IPX_NODE_LEN];
|
| 82 | struct list_head node;
|
| 83 | atomic_t refcnt;
|
| 84 | };
|
| 85 |
|
| 86 | struct ipx_cb {
|
| 87 | u8 ipx_tctrl;
|
| 88 | __be32 ipx_dest_net;
|
| 89 | __be32 ipx_source_net;
|
| 90 | struct {
|
| 91 | __be32 netnum;
|
| 92 | int index;
|
| 93 | } last_hop;
|
| 94 | };
|
| 95 |
|
| 96 | #include <net/sock.h>
|
| 97 |
|
| 98 | struct ipx_sock {
|
| 99 |
|
| 100 | struct sock sk;
|
| 101 | struct ipx_address dest_addr;
|
| 102 | struct ipx_interface *intrfc;
|
| 103 | __be16 port;
|
| 104 | #ifdef CONFIG_IPX_INTERN
|
| 105 | unsigned char node[IPX_NODE_LEN];
|
| 106 | #endif
|
| 107 | unsigned short type;
|
| 108 | |
| 109 | * To handle special ncp connection-handling sockets for mars_nwe,
|
| 110 | * the connection number must be stored in the socket.
|
| 111 |
|
| 112 | unsigned short ipx_ncp_conn;
|
| 113 | };
|
| 114 |
|
| 115 | static inline struct ipx_sock *ipx_sk(struct sock *sk)
|
| 116 | {
|
| 117 | return (struct ipx_sock *)sk;
|
| 118 | }
|
| 119 |
|
| 120 | #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
|
| 121 |
|
| 122 | #define IPX_MIN_EPHEMERAL_SOCKET 0x4000
|
| 123 | #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
|
| 124 |
|
| 125 | extern struct list_head ipx_routes;
|
| 126 | extern rwlock_t ipx_routes_lock;
|
| 127 |
|
| 128 | extern struct list_head ipx_interfaces;
|
| 129 | struct ipx_interface *ipx_interfaces_head(void);
|
| 130 | extern spinlock_t ipx_interfaces_lock;
|
| 131 |
|
| 132 | extern struct ipx_interface *ipx_primary_net;
|
| 133 |
|
| 134 | int ipx_proc_init(void);
|
| 135 | void ipx_proc_exit(void);
|
| 136 |
|
| 137 | const char *ipx_frame_name(__be16);
|
| 138 | const char *ipx_device_name(struct ipx_interface *intrfc);
|
| 139 |
|
| 140 | static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
|
| 141 | {
|
| 142 | atomic_inc(&intrfc->refcnt);
|
| 143 | }
|
| 144 |
|
| 145 | void ipxitf_down(struct ipx_interface *intrfc);
|
| 146 | struct ipx_interface *ipxitf_find_using_net(__be32 net);
|
| 147 | int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node);
|
| 148 | __be16 ipx_cksum(struct ipxhdr *packet, int length);
|
| 149 | int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
|
| 150 | unsigned char *node);
|
| 151 | void ipxrtr_del_routes(struct ipx_interface *intrfc);
|
| 152 | int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
|
| 153 | struct msghdr *msg, size_t len, int noblock);
|
| 154 | int ipxrtr_route_skb(struct sk_buff *skb);
|
| 155 | struct ipx_route *ipxrtr_lookup(__be32 net);
|
| 156 | int ipxrtr_ioctl(unsigned int cmd, void __user *arg);
|
| 157 |
|
| 158 | static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
|
| 159 | {
|
| 160 | if (atomic_dec_and_test(&intrfc->refcnt))
|
| 161 | ipxitf_down(intrfc);
|
| 162 | }
|
| 163 |
|
| 164 | static __inline__ void ipxrtr_hold(struct ipx_route *rt)
|
| 165 | {
|
| 166 | atomic_inc(&rt->refcnt);
|
| 167 | }
|
| 168 |
|
| 169 | static __inline__ void ipxrtr_put(struct ipx_route *rt)
|
| 170 | {
|
| 171 | if (atomic_dec_and_test(&rt->refcnt))
|
| 172 | kfree(rt);
|
| 173 | }
|
| 174 | #endif
|