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