Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _NET_INET_IPX_H_
3#define _NET_INET_IPX_H_
4/*
5 * The following information is in its entirety obtained from:
6 *
7 * Novell 'IPX Router Specification' Version 1.10
8 * Part No. 107-000029-001
9 *
10 * Which is available from ftp.novell.com
11 */
12
13#include <linux/netdevice.h>
14#include <net/datalink.h>
15#include <linux/ipx.h>
16#include <linux/list.h>
17#include <linux/slab.h>
18#include <linux/refcount.h>
19
20struct ipx_address {
21 __be32 net;
22 __u8 node[IPX_NODE_LEN];
23 __be16 sock;
24};
25
26#define ipx_broadcast_node "\377\377\377\377\377\377"
27#define ipx_this_node "\0\0\0\0\0\0"
28
29#define IPX_MAX_PPROP_HOPS 8
30
31struct ipxhdr {
32 __be16 ipx_checksum __packed;
33#define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF)
34 __be16 ipx_pktsize __packed;
35 __u8 ipx_tctrl;
36 __u8 ipx_type;
37#define IPX_TYPE_UNKNOWN 0x00
38#define IPX_TYPE_RIP 0x01 /* may also be 0 */
39#define IPX_TYPE_SAP 0x04 /* may also be 0 */
40#define IPX_TYPE_SPX 0x05 /* SPX protocol */
41#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
42#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */
43 struct ipx_address ipx_dest __packed;
44 struct ipx_address ipx_source __packed;
45};
46
47/* From af_ipx.c */
48extern int sysctl_ipx_pprop_broadcasting;
49
50struct ipx_interface {
51 /* IPX address */
52 __be32 if_netnum;
53 unsigned char if_node[IPX_NODE_LEN];
54 refcount_t refcnt;
55
56 /* physical device info */
57 struct net_device *if_dev;
58 struct datalink_proto *if_dlink;
59 __be16 if_dlink_type;
60
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 {
75 __be32 ir_net;
76 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 refcount_t refcnt;
81};
82
83struct ipx_cb {
84 u8 ipx_tctrl;
85 __be32 ipx_dest_net;
86 __be32 ipx_source_net;
87 struct {
88 __be32 netnum;
89 int index;
90 } last_hop;
91};
92
93#include <net/sock.h>
94
95struct 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;
100 __be16 port;
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
112static 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
119#define IPX_MIN_EPHEMERAL_SOCKET 0x4000
120#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
121
122extern struct list_head ipx_routes;
123extern rwlock_t ipx_routes_lock;
124
125extern struct list_head ipx_interfaces;
126struct ipx_interface *ipx_interfaces_head(void);
127extern spinlock_t ipx_interfaces_lock;
128
129extern struct ipx_interface *ipx_primary_net;
130
131int ipx_proc_init(void);
132void ipx_proc_exit(void);
133
134const char *ipx_frame_name(__be16);
135const char *ipx_device_name(struct ipx_interface *intrfc);
136
137static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
138{
139 refcount_inc(&intrfc->refcnt);
140}
141
142void ipxitf_down(struct ipx_interface *intrfc);
143struct ipx_interface *ipxitf_find_using_net(__be32 net);
144int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node);
145__be16 ipx_cksum(struct ipxhdr *packet, int length);
146int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
147 unsigned char *node);
148void ipxrtr_del_routes(struct ipx_interface *intrfc);
149int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
150 struct msghdr *msg, size_t len, int noblock);
151int ipxrtr_route_skb(struct sk_buff *skb);
152struct ipx_route *ipxrtr_lookup(__be32 net);
153int ipxrtr_ioctl(unsigned int cmd, void __user *arg);
154
155static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
156{
157 if (refcount_dec_and_test(&intrfc->refcnt))
158 ipxitf_down(intrfc);
159}
160
161static __inline__ void ipxrtr_hold(struct ipx_route *rt)
162{
163 refcount_inc(&rt->refcnt);
164}
165
166static __inline__ void ipxrtr_put(struct ipx_route *rt)
167{
168 if (refcount_dec_and_test(&rt->refcnt))
169 kfree(rt);
170}
171#endif /* _NET_INET_IPX_H_ */
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
18struct 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
29struct 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 /* 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 __packed;
42 struct ipx_address ipx_source __packed;
43};
44
45static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
46{
47 return (struct ipxhdr *)skb_transport_header(skb);
48}
49
50struct ipx_interface {
51 /* IPX address */
52 __be32 if_netnum;
53 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;
59 __be16 if_dlink_type;
60
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 {
75 __be32 ir_net;
76 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
83struct ipx_cb {
84 u8 ipx_tctrl;
85 __be32 ipx_dest_net;
86 __be32 ipx_source_net;
87 struct {
88 __be32 netnum;
89 int index;
90 } last_hop;
91};
92
93#include <net/sock.h>
94
95struct 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;
100 __be16 port;
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
112static 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
119#define IPX_MIN_EPHEMERAL_SOCKET 0x4000
120#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
121
122extern struct list_head ipx_routes;
123extern rwlock_t ipx_routes_lock;
124
125extern struct list_head ipx_interfaces;
126extern struct ipx_interface *ipx_interfaces_head(void);
127extern spinlock_t ipx_interfaces_lock;
128
129extern struct ipx_interface *ipx_primary_net;
130
131extern int ipx_proc_init(void);
132extern void ipx_proc_exit(void);
133
134extern const char *ipx_frame_name(__be16);
135extern const char *ipx_device_name(struct ipx_interface *intrfc);
136
137static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
138{
139 atomic_inc(&intrfc->refcnt);
140}
141
142extern void ipxitf_down(struct ipx_interface *intrfc);
143
144static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
145{
146 if (atomic_dec_and_test(&intrfc->refcnt))
147 ipxitf_down(intrfc);
148}
149
150static __inline__ void ipxrtr_hold(struct ipx_route *rt)
151{
152 atomic_inc(&rt->refcnt);
153}
154
155static __inline__ void ipxrtr_put(struct ipx_route *rt)
156{
157 if (atomic_dec_and_test(&rt->refcnt))
158 kfree(rt);
159}
160#endif /* _NET_INET_IPX_H_ */