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> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Reshetova, Elena | d25189c | 2017-07-04 15:53:09 +0300 | [diff] [blame^] | 17 | #include <linux/refcount.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | struct ipx_address { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 20 | __be32 net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | __u8 node[IPX_NODE_LEN]; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 22 | __be16 sock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | #define ipx_broadcast_node "\377\377\377\377\377\377" |
| 26 | #define ipx_this_node "\0\0\0\0\0\0" |
| 27 | |
| 28 | #define IPX_MAX_PPROP_HOPS 8 |
| 29 | |
| 30 | struct ipxhdr { |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 31 | __be16 ipx_checksum __packed; |
Harvey Harrison | f3a7c66 | 2009-02-14 22:58:35 -0800 | [diff] [blame] | 32 | #define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF) |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 33 | __be16 ipx_pktsize __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | __u8 ipx_tctrl; |
| 35 | __u8 ipx_type; |
| 36 | #define IPX_TYPE_UNKNOWN 0x00 |
| 37 | #define IPX_TYPE_RIP 0x01 /* may also be 0 */ |
| 38 | #define IPX_TYPE_SAP 0x04 /* may also be 0 */ |
| 39 | #define IPX_TYPE_SPX 0x05 /* SPX protocol */ |
| 40 | #define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */ |
| 41 | #define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */ |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 42 | struct ipx_address ipx_dest __packed; |
| 43 | struct ipx_address ipx_source __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
Fabian Frederick | 5e96d78 | 2014-10-27 20:00:41 +0100 | [diff] [blame] | 46 | /* From af_ipx.c */ |
| 47 | extern int sysctl_ipx_pprop_broadcasting; |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb) |
| 50 | { |
Arnaldo Carvalho de Melo | 9c70220 | 2007-04-25 18:04:18 -0700 | [diff] [blame] | 51 | return (struct ipxhdr *)skb_transport_header(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | struct ipx_interface { |
| 55 | /* IPX address */ |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 56 | __be32 if_netnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | unsigned char if_node[IPX_NODE_LEN]; |
Reshetova, Elena | d25189c | 2017-07-04 15:53:09 +0300 | [diff] [blame^] | 58 | refcount_t refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /* physical device info */ |
| 61 | struct net_device *if_dev; |
| 62 | struct datalink_proto *if_dlink; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 63 | __be16 if_dlink_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | /* socket support */ |
| 66 | unsigned short if_sknum; |
| 67 | struct hlist_head if_sklist; |
| 68 | spinlock_t if_sklist_lock; |
| 69 | |
| 70 | /* administrative overhead */ |
| 71 | int if_ipx_offset; |
| 72 | unsigned char if_internal; |
| 73 | unsigned char if_primary; |
| 74 | |
| 75 | struct list_head node; /* node in ipx_interfaces list */ |
| 76 | }; |
| 77 | |
| 78 | struct ipx_route { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 79 | __be32 ir_net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | struct ipx_interface *ir_intrfc; |
| 81 | unsigned char ir_routed; |
| 82 | unsigned char ir_router_node[IPX_NODE_LEN]; |
| 83 | struct list_head node; /* node in ipx_routes list */ |
| 84 | atomic_t refcnt; |
| 85 | }; |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct ipx_cb { |
| 88 | u8 ipx_tctrl; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 89 | __be32 ipx_dest_net; |
| 90 | __be32 ipx_source_net; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | struct { |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 92 | __be32 netnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | int index; |
| 94 | } last_hop; |
| 95 | }; |
| 96 | |
| 97 | #include <net/sock.h> |
| 98 | |
| 99 | struct ipx_sock { |
| 100 | /* struct sock has to be the first member of ipx_sock */ |
| 101 | struct sock sk; |
| 102 | struct ipx_address dest_addr; |
| 103 | struct ipx_interface *intrfc; |
Al Viro | 4833ed0 | 2006-11-03 00:27:06 -0800 | [diff] [blame] | 104 | __be16 port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #ifdef CONFIG_IPX_INTERN |
| 106 | unsigned char node[IPX_NODE_LEN]; |
| 107 | #endif |
| 108 | unsigned short type; |
| 109 | /* |
| 110 | * To handle special ncp connection-handling sockets for mars_nwe, |
| 111 | * the connection number must be stored in the socket. |
| 112 | */ |
| 113 | unsigned short ipx_ncp_conn; |
| 114 | }; |
| 115 | |
| 116 | static inline struct ipx_sock *ipx_sk(struct sock *sk) |
| 117 | { |
| 118 | return (struct ipx_sock *)sk; |
| 119 | } |
| 120 | |
| 121 | #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | #define IPX_MIN_EPHEMERAL_SOCKET 0x4000 |
| 124 | #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff |
| 125 | |
| 126 | extern struct list_head ipx_routes; |
| 127 | extern rwlock_t ipx_routes_lock; |
| 128 | |
| 129 | extern struct list_head ipx_interfaces; |
Joe Perches | 9d03626 | 2013-09-21 10:22:43 -0700 | [diff] [blame] | 130 | struct ipx_interface *ipx_interfaces_head(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | extern spinlock_t ipx_interfaces_lock; |
| 132 | |
| 133 | extern struct ipx_interface *ipx_primary_net; |
| 134 | |
Joe Perches | 9d03626 | 2013-09-21 10:22:43 -0700 | [diff] [blame] | 135 | int ipx_proc_init(void); |
| 136 | void ipx_proc_exit(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Joe Perches | 9d03626 | 2013-09-21 10:22:43 -0700 | [diff] [blame] | 138 | const char *ipx_frame_name(__be16); |
| 139 | const char *ipx_device_name(struct ipx_interface *intrfc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | static __inline__ void ipxitf_hold(struct ipx_interface *intrfc) |
| 142 | { |
Reshetova, Elena | d25189c | 2017-07-04 15:53:09 +0300 | [diff] [blame^] | 143 | refcount_inc(&intrfc->refcnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Joe Perches | 9d03626 | 2013-09-21 10:22:43 -0700 | [diff] [blame] | 146 | void ipxitf_down(struct ipx_interface *intrfc); |
Rashika Kheria | 493cc5e | 2014-02-09 22:24:33 +0530 | [diff] [blame] | 147 | struct ipx_interface *ipxitf_find_using_net(__be32 net); |
| 148 | int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node); |
| 149 | __be16 ipx_cksum(struct ipxhdr *packet, int length); |
Rashika Kheria | 578efbc | 2014-02-09 22:26:32 +0530 | [diff] [blame] | 150 | int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc, |
| 151 | unsigned char *node); |
| 152 | void ipxrtr_del_routes(struct ipx_interface *intrfc); |
| 153 | int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, |
Al Viro | e169371 | 2014-04-06 21:28:01 -0400 | [diff] [blame] | 154 | struct msghdr *msg, size_t len, int noblock); |
Rashika Kheria | 578efbc | 2014-02-09 22:26:32 +0530 | [diff] [blame] | 155 | int ipxrtr_route_skb(struct sk_buff *skb); |
| 156 | struct ipx_route *ipxrtr_lookup(__be32 net); |
| 157 | int ipxrtr_ioctl(unsigned int cmd, void __user *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | static __inline__ void ipxitf_put(struct ipx_interface *intrfc) |
| 160 | { |
Reshetova, Elena | d25189c | 2017-07-04 15:53:09 +0300 | [diff] [blame^] | 161 | if (refcount_dec_and_test(&intrfc->refcnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | ipxitf_down(intrfc); |
| 163 | } |
| 164 | |
| 165 | static __inline__ void ipxrtr_hold(struct ipx_route *rt) |
| 166 | { |
| 167 | atomic_inc(&rt->refcnt); |
| 168 | } |
| 169 | |
| 170 | static __inline__ void ipxrtr_put(struct ipx_route *rt) |
| 171 | { |
| 172 | if (atomic_dec_and_test(&rt->refcnt)) |
| 173 | kfree(rt); |
| 174 | } |
| 175 | #endif /* _NET_INET_IPX_H_ */ |