blob: ef51a668ba191b6c2d3d4a62df21a6b47482c363 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 Heo5a0e3ad2010-03-24 17:04:11 +090016#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18struct ipx_address {
Al Viro4833ed02006-11-03 00:27:06 -080019 __be32 net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 __u8 node[IPX_NODE_LEN];
Al Viro4833ed02006-11-03 00:27:06 -080021 __be16 sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022};
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
29struct ipxhdr {
Al Viro02e60372006-11-03 00:28:23 -080030 __be16 ipx_checksum __attribute__ ((packed));
Harvey Harrisonf3a7c662009-02-14 22:58:35 -080031#define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF)
Al Viro4833ed02006-11-03 00:27:06 -080032 __be16 ipx_pktsize __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 __u8 ipx_tctrl;
34 __u8 ipx_type;
35#define IPX_TYPE_UNKNOWN 0x00
36#define IPX_TYPE_RIP 0x01 /* may also be 0 */
37#define IPX_TYPE_SAP 0x04 /* may also be 0 */
38#define IPX_TYPE_SPX 0x05 /* SPX protocol */
39#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
40#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */
41 struct ipx_address ipx_dest __attribute__ ((packed));
42 struct ipx_address ipx_source __attribute__ ((packed));
43};
44
45static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
46{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070047 return (struct ipxhdr *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
50struct ipx_interface {
51 /* IPX address */
Al Viro4833ed02006-11-03 00:27:06 -080052 __be32 if_netnum;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 unsigned char if_node[IPX_NODE_LEN];
54 atomic_t refcnt;
55
56 /* physical device info */
57 struct net_device *if_dev;
58 struct datalink_proto *if_dlink;
Al Viro4833ed02006-11-03 00:27:06 -080059 __be16 if_dlink_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 /* socket support */
62 unsigned short if_sknum;
63 struct hlist_head if_sklist;
64 spinlock_t if_sklist_lock;
65
66 /* administrative overhead */
67 int if_ipx_offset;
68 unsigned char if_internal;
69 unsigned char if_primary;
70
71 struct list_head node; /* node in ipx_interfaces list */
72};
73
74struct ipx_route {
Al Viro4833ed02006-11-03 00:27:06 -080075 __be32 ir_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 struct ipx_interface *ir_intrfc;
77 unsigned char ir_routed;
78 unsigned char ir_router_node[IPX_NODE_LEN];
79 struct list_head node; /* node in ipx_routes list */
80 atomic_t refcnt;
81};
82
83#ifdef __KERNEL__
84struct ipx_cb {
85 u8 ipx_tctrl;
Al Viro4833ed02006-11-03 00:27:06 -080086 __be32 ipx_dest_net;
87 __be32 ipx_source_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 struct {
Al Viro4833ed02006-11-03 00:27:06 -080089 __be32 netnum;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 int index;
91 } last_hop;
92};
93
94#include <net/sock.h>
95
96struct ipx_sock {
97 /* struct sock has to be the first member of ipx_sock */
98 struct sock sk;
99 struct ipx_address dest_addr;
100 struct ipx_interface *intrfc;
Al Viro4833ed02006-11-03 00:27:06 -0800101 __be16 port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#ifdef CONFIG_IPX_INTERN
103 unsigned char node[IPX_NODE_LEN];
104#endif
105 unsigned short type;
106 /*
107 * To handle special ncp connection-handling sockets for mars_nwe,
108 * the connection number must be stored in the socket.
109 */
110 unsigned short ipx_ncp_conn;
111};
112
113static inline struct ipx_sock *ipx_sk(struct sock *sk)
114{
115 return (struct ipx_sock *)sk;
116}
117
118#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
119#endif
120
121#define IPX_MIN_EPHEMERAL_SOCKET 0x4000
122#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
123
124extern struct list_head ipx_routes;
125extern rwlock_t ipx_routes_lock;
126
127extern struct list_head ipx_interfaces;
128extern struct ipx_interface *ipx_interfaces_head(void);
129extern spinlock_t ipx_interfaces_lock;
130
131extern struct ipx_interface *ipx_primary_net;
132
133extern int ipx_proc_init(void);
134extern void ipx_proc_exit(void);
135
Al Viro4833ed02006-11-03 00:27:06 -0800136extern const char *ipx_frame_name(__be16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137extern const char *ipx_device_name(struct ipx_interface *intrfc);
138
139static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
140{
141 atomic_inc(&intrfc->refcnt);
142}
143
144extern void ipxitf_down(struct ipx_interface *intrfc);
145
146static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
147{
148 if (atomic_dec_and_test(&intrfc->refcnt))
149 ipxitf_down(intrfc);
150}
151
152static __inline__ void ipxrtr_hold(struct ipx_route *rt)
153{
154 atomic_inc(&rt->refcnt);
155}
156
157static __inline__ void ipxrtr_put(struct ipx_route *rt)
158{
159 if (atomic_dec_and_test(&rt->refcnt))
160 kfree(rt);
161}
162#endif /* _NET_INET_IPX_H_ */