ipx.h 3.8 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. struct ipx_address {
  16. __be32 net;
  17. __u8 node[IPX_NODE_LEN];
  18. __be16 sock;
  19. };
  20. #define ipx_broadcast_node "\377\377\377\377\377\377"
  21. #define ipx_this_node "\0\0\0\0\0\0"
  22. #define IPX_MAX_PPROP_HOPS 8
  23. struct ipxhdr {
  24. __be16 ipx_checksum __attribute__ ((packed));
  25. #define IPX_NO_CHECKSUM __constant_htons(0xFFFF)
  26. __be16 ipx_pktsize __attribute__ ((packed));
  27. __u8 ipx_tctrl;
  28. __u8 ipx_type;
  29. #define IPX_TYPE_UNKNOWN 0x00
  30. #define IPX_TYPE_RIP 0x01 /* may also be 0 */
  31. #define IPX_TYPE_SAP 0x04 /* may also be 0 */
  32. #define IPX_TYPE_SPX 0x05 /* SPX protocol */
  33. #define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
  34. #define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */
  35. struct ipx_address ipx_dest __attribute__ ((packed));
  36. struct ipx_address ipx_source __attribute__ ((packed));
  37. };
  38. static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
  39. {
  40. return (struct ipxhdr *)skb_transport_header(skb);
  41. }
  42. struct ipx_interface {
  43. /* IPX address */
  44. __be32 if_netnum;
  45. unsigned char if_node[IPX_NODE_LEN];
  46. atomic_t refcnt;
  47. /* physical device info */
  48. struct net_device *if_dev;
  49. struct datalink_proto *if_dlink;
  50. __be16 if_dlink_type;
  51. /* socket support */
  52. unsigned short if_sknum;
  53. struct hlist_head if_sklist;
  54. spinlock_t if_sklist_lock;
  55. /* administrative overhead */
  56. int if_ipx_offset;
  57. unsigned char if_internal;
  58. unsigned char if_primary;
  59. struct list_head node; /* node in ipx_interfaces list */
  60. };
  61. struct ipx_route {
  62. __be32 ir_net;
  63. struct ipx_interface *ir_intrfc;
  64. unsigned char ir_routed;
  65. unsigned char ir_router_node[IPX_NODE_LEN];
  66. struct list_head node; /* node in ipx_routes list */
  67. atomic_t refcnt;
  68. };
  69. #ifdef __KERNEL__
  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. #endif
  102. #define IPX_MIN_EPHEMERAL_SOCKET 0x4000
  103. #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
  104. extern struct list_head ipx_routes;
  105. extern rwlock_t ipx_routes_lock;
  106. extern struct list_head ipx_interfaces;
  107. extern struct ipx_interface *ipx_interfaces_head(void);
  108. extern spinlock_t ipx_interfaces_lock;
  109. extern struct ipx_interface *ipx_primary_net;
  110. extern int ipx_proc_init(void);
  111. extern void ipx_proc_exit(void);
  112. extern const char *ipx_frame_name(__be16);
  113. extern const char *ipx_device_name(struct ipx_interface *intrfc);
  114. static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
  115. {
  116. atomic_inc(&intrfc->refcnt);
  117. }
  118. extern void ipxitf_down(struct ipx_interface *intrfc);
  119. static __inline__ void ipxitf_put(struct ipx_interface *intrfc)
  120. {
  121. if (atomic_dec_and_test(&intrfc->refcnt))
  122. ipxitf_down(intrfc);
  123. }
  124. static __inline__ void ipxrtr_hold(struct ipx_route *rt)
  125. {
  126. atomic_inc(&rt->refcnt);
  127. }
  128. static __inline__ void ipxrtr_put(struct ipx_route *rt)
  129. {
  130. if (atomic_dec_and_test(&rt->refcnt))
  131. kfree(rt);
  132. }
  133. #endif /* _NET_INET_IPX_H_ */