ipx.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. struct ipx_interface {
  44. /* IPX address */
  45. __be32 if_netnum;
  46. unsigned char if_node[IPX_NODE_LEN];
  47. refcount_t refcnt;
  48. /* physical device info */
  49. struct net_device *if_dev;
  50. struct datalink_proto *if_dlink;
  51. __be16 if_dlink_type;
  52. /* socket support */
  53. unsigned short if_sknum;
  54. struct hlist_head if_sklist;
  55. spinlock_t if_sklist_lock;
  56. /* administrative overhead */
  57. int if_ipx_offset;
  58. unsigned char if_internal;
  59. unsigned char if_primary;
  60. struct list_head node; /* node in ipx_interfaces list */
  61. };
  62. struct ipx_route {
  63. __be32 ir_net;
  64. struct ipx_interface *ir_intrfc;
  65. unsigned char ir_routed;
  66. unsigned char ir_router_node[IPX_NODE_LEN];
  67. struct list_head node; /* node in ipx_routes list */
  68. refcount_t refcnt;
  69. };
  70. struct ipx_cb {
  71. u8 ipx_tctrl;
  72. __be32 ipx_dest_net;
  73. __be32 ipx_source_net;
  74. struct {
  75. __be32 netnum;
  76. int index;
  77. } last_hop;
  78. };
  79. #include <net/sock.h>
  80. struct ipx_sock {
  81. /* struct sock has to be the first member of ipx_sock */
  82. struct sock sk;
  83. struct ipx_address dest_addr;
  84. struct ipx_interface *intrfc;
  85. __be16 port;
  86. #ifdef CONFIG_IPX_INTERN
  87. unsigned char node[IPX_NODE_LEN];
  88. #endif
  89. unsigned short type;
  90. /*
  91. * To handle special ncp connection-handling sockets for mars_nwe,
  92. * the connection number must be stored in the socket.
  93. */
  94. unsigned short ipx_ncp_conn;
  95. };
  96. static inline struct ipx_sock *ipx_sk(struct sock *sk)
  97. {
  98. return (struct ipx_sock *)sk;
  99. }
  100. #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
  101. #define IPX_MIN_EPHEMERAL_SOCKET 0x4000
  102. #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
  103. extern struct list_head ipx_routes;
  104. extern rwlock_t ipx_routes_lock;
  105. extern struct list_head ipx_interfaces;
  106. struct ipx_interface *ipx_interfaces_head(void);
  107. extern spinlock_t ipx_interfaces_lock;
  108. extern struct ipx_interface *ipx_primary_net;
  109. int ipx_proc_init(void);
  110. void ipx_proc_exit(void);
  111. const char *ipx_frame_name(__be16);
  112. const char *ipx_device_name(struct ipx_interface *intrfc);
  113. static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
  114. {
  115. refcount_inc(&intrfc->refcnt);
  116. }
  117. void ipxitf_down(struct ipx_interface *intrfc);
  118. struct ipx_interface *ipxitf_find_using_net(__be32 net);
  119. int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node);
  120. __be16 ipx_cksum(struct ipxhdr *packet, int length);
  121. int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
  122. unsigned char *node);
  123. void ipxrtr_del_routes(struct ipx_interface *intrfc);
  124. int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
  125. struct msghdr *msg, size_t len, int noblock);
  126. int ipxrtr_route_skb(struct sk_buff *skb);
  127. struct ipx_route *ipxrtr_lookup(__be32 net);
  128. int ipxrtr_ioctl(unsigned int cmd, void __user *arg);
  129. static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
  130. {
  131. if (refcount_dec_and_test(&intrfc->refcnt))
  132. ipxitf_down(intrfc);
  133. }
  134. static __inline__ void ipxrtr_hold(struct ipx_route *rt)
  135. {
  136. refcount_inc(&rt->refcnt);
  137. }
  138. static __inline__ void ipxrtr_put(struct ipx_route *rt)
  139. {
  140. if (refcount_dec_and_test(&rt->refcnt))
  141. kfree(rt);
  142. }
  143. #endif /* _NET_INET_IPX_H_ */