ipx.h 4.3 KB

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