ipx.h 4.4 KB

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