ipx.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. #include <linux/netdevice.h>
  12. #include <net/datalink.h>
  13. #include <linux/ipx.h>
  14. #include <linux/list.h>
  15. #include <linux/slab.h>
  16. struct ipx_address {
  17. __be32 net;
  18. __u8 node[IPX_NODE_LEN];
  19. __be16 sock;
  20. };
  21. #define ipx_broadcast_node "\377\377\377\377\377\377"
  22. #define ipx_this_node "\0\0\0\0\0\0"
  23. #define IPX_MAX_PPROP_HOPS 8
  24. struct ipxhdr {
  25. __be16 ipx_checksum __packed;
  26. #define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF)
  27. __be16 ipx_pktsize __packed;
  28. __u8 ipx_tctrl;
  29. __u8 ipx_type;
  30. #define IPX_TYPE_UNKNOWN 0x00
  31. #define IPX_TYPE_RIP 0x01 /* may also be 0 */
  32. #define IPX_TYPE_SAP 0x04 /* may also be 0 */
  33. #define IPX_TYPE_SPX 0x05 /* SPX protocol */
  34. #define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
  35. #define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */
  36. struct ipx_address ipx_dest __packed;
  37. struct ipx_address ipx_source __packed;
  38. };
  39. static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
  40. {
  41. return (struct ipxhdr *)skb_transport_header(skb);
  42. }
  43. struct ipx_interface {
  44. /* IPX address */
  45. __be32 if_netnum;
  46. unsigned char if_node[IPX_NODE_LEN];
  47. atomic_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. atomic_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. extern struct ipx_interface *ipx_interfaces_head(void);
  107. extern spinlock_t ipx_interfaces_lock;
  108. extern struct ipx_interface *ipx_primary_net;
  109. extern int ipx_proc_init(void);
  110. extern void ipx_proc_exit(void);
  111. extern const char *ipx_frame_name(__be16);
  112. extern const char *ipx_device_name(struct ipx_interface *intrfc);
  113. static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
  114. {
  115. atomic_inc(&intrfc->refcnt);
  116. }
  117. extern void ipxitf_down(struct ipx_interface *intrfc);
  118. static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
  119. {
  120. if (atomic_dec_and_test(&intrfc->refcnt))
  121. ipxitf_down(intrfc);
  122. }
  123. static __inline__ void ipxrtr_hold(struct ipx_route *rt)
  124. {
  125. atomic_inc(&rt->refcnt);
  126. }
  127. static __inline__ void ipxrtr_put(struct ipx_route *rt)
  128. {
  129. if (atomic_dec_and_test(&rt->refcnt))
  130. kfree(rt);
  131. }
  132. #endif /* _NET_INET_IPX_H_ */