ipx.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. #ifdef __KERNEL__
  71. struct ipx_cb {
  72. u8 ipx_tctrl;
  73. __be32 ipx_dest_net;
  74. __be32 ipx_source_net;
  75. struct {
  76. __be32 netnum;
  77. int index;
  78. } last_hop;
  79. };
  80. #include <net/sock.h>
  81. struct ipx_sock {
  82. /* struct sock has to be the first member of ipx_sock */
  83. struct sock sk;
  84. struct ipx_address dest_addr;
  85. struct ipx_interface *intrfc;
  86. __be16 port;
  87. #ifdef CONFIG_IPX_INTERN
  88. unsigned char node[IPX_NODE_LEN];
  89. #endif
  90. unsigned short type;
  91. /*
  92. * To handle special ncp connection-handling sockets for mars_nwe,
  93. * the connection number must be stored in the socket.
  94. */
  95. unsigned short ipx_ncp_conn;
  96. };
  97. static inline struct ipx_sock *ipx_sk(struct sock *sk)
  98. {
  99. return (struct ipx_sock *)sk;
  100. }
  101. #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
  102. #endif
  103. #define IPX_MIN_EPHEMERAL_SOCKET 0x4000
  104. #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
  105. extern struct list_head ipx_routes;
  106. extern rwlock_t ipx_routes_lock;
  107. extern struct list_head ipx_interfaces;
  108. extern struct ipx_interface *ipx_interfaces_head(void);
  109. extern spinlock_t ipx_interfaces_lock;
  110. extern struct ipx_interface *ipx_primary_net;
  111. extern int ipx_proc_init(void);
  112. extern void ipx_proc_exit(void);
  113. extern const char *ipx_frame_name(__be16);
  114. extern const char *ipx_device_name(struct ipx_interface *intrfc);
  115. static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
  116. {
  117. atomic_inc(&intrfc->refcnt);
  118. }
  119. extern void ipxitf_down(struct ipx_interface *intrfc);
  120. static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
  121. {
  122. if (atomic_dec_and_test(&intrfc->refcnt))
  123. ipxitf_down(intrfc);
  124. }
  125. static __inline__ void ipxrtr_hold(struct ipx_route *rt)
  126. {
  127. atomic_inc(&rt->refcnt);
  128. }
  129. static __inline__ void ipxrtr_put(struct ipx_route *rt)
  130. {
  131. if (atomic_dec_and_test(&rt->refcnt))
  132. kfree(rt);
  133. }
  134. #endif /* _NET_INET_IPX_H_ */