dn_route.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef _NET_DN_ROUTE_H
  2. #define _NET_DN_ROUTE_H
  3. /******************************************************************************
  4. (c) 1995-1998 E.M. Serrat emserrat@geocities.com
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. *******************************************************************************/
  14. struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
  15. int dn_route_output_sock(struct dst_entry __rcu **pprt, struct flowidn *,
  16. struct sock *sk, int flags);
  17. int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
  18. void dn_rt_cache_flush(int delay);
  19. int dn_route_rcv(struct sk_buff *skb, struct net_device *dev,
  20. struct packet_type *pt, struct net_device *orig_dev);
  21. /* Masks for flags field */
  22. #define DN_RT_F_PID 0x07 /* Mask for packet type */
  23. #define DN_RT_F_PF 0x80 /* Padding Follows */
  24. #define DN_RT_F_VER 0x40 /* Version =0 discard packet if ==1 */
  25. #define DN_RT_F_IE 0x20 /* Intra Ethernet, Reserved in short pkt */
  26. #define DN_RT_F_RTS 0x10 /* Packet is being returned to sender */
  27. #define DN_RT_F_RQR 0x08 /* Return packet to sender upon non-delivery */
  28. /* Mask for types of routing packets */
  29. #define DN_RT_PKT_MSK 0x06
  30. /* Types of routing packets */
  31. #define DN_RT_PKT_SHORT 0x02 /* Short routing packet */
  32. #define DN_RT_PKT_LONG 0x06 /* Long routing packet */
  33. /* Mask for control/routing selection */
  34. #define DN_RT_PKT_CNTL 0x01 /* Set to 1 if a control packet */
  35. /* Types of control packets */
  36. #define DN_RT_CNTL_MSK 0x0f /* Mask for control packets */
  37. #define DN_RT_PKT_INIT 0x01 /* Initialisation packet */
  38. #define DN_RT_PKT_VERI 0x03 /* Verification Message */
  39. #define DN_RT_PKT_HELO 0x05 /* Hello and Test Message */
  40. #define DN_RT_PKT_L1RT 0x07 /* Level 1 Routing Message */
  41. #define DN_RT_PKT_L2RT 0x09 /* Level 2 Routing Message */
  42. #define DN_RT_PKT_ERTH 0x0b /* Ethernet Router Hello */
  43. #define DN_RT_PKT_EEDH 0x0d /* Ethernet EndNode Hello */
  44. /* Values for info field in hello message */
  45. #define DN_RT_INFO_TYPE 0x03 /* Type mask */
  46. #define DN_RT_INFO_L1RT 0x02 /* L1 Router */
  47. #define DN_RT_INFO_L2RT 0x01 /* L2 Router */
  48. #define DN_RT_INFO_ENDN 0x03 /* EndNode */
  49. #define DN_RT_INFO_VERI 0x04 /* Verification Reqd. */
  50. #define DN_RT_INFO_RJCT 0x08 /* Reject Flag, Reserved */
  51. #define DN_RT_INFO_VFLD 0x10 /* Verification Failed, Reserved */
  52. #define DN_RT_INFO_NOML 0x20 /* No Multicast traffic accepted */
  53. #define DN_RT_INFO_BLKR 0x40 /* Blocking Requested */
  54. /*
  55. * The fl structure is what we used to look up the route.
  56. * The rt_saddr & rt_daddr entries are the same as key.saddr & key.daddr
  57. * except for local input routes, where the rt_saddr = fl.fld_dst and
  58. * rt_daddr = fl.fld_src to allow the route to be used for returning
  59. * packets to the originating host.
  60. */
  61. struct dn_route {
  62. struct dst_entry dst;
  63. struct neighbour *n;
  64. struct flowidn fld;
  65. __le16 rt_saddr;
  66. __le16 rt_daddr;
  67. __le16 rt_gateway;
  68. __le16 rt_local_src; /* Source used for forwarding packets */
  69. __le16 rt_src_map;
  70. __le16 rt_dst_map;
  71. unsigned int rt_flags;
  72. unsigned int rt_type;
  73. };
  74. static inline bool dn_is_input_route(struct dn_route *rt)
  75. {
  76. return rt->fld.flowidn_iif != 0;
  77. }
  78. static inline bool dn_is_output_route(struct dn_route *rt)
  79. {
  80. return rt->fld.flowidn_iif == 0;
  81. }
  82. void dn_route_init(void);
  83. void dn_route_cleanup(void);
  84. #include <net/sock.h>
  85. #include <linux/if_arp.h>
  86. static inline void dn_rt_send(struct sk_buff *skb)
  87. {
  88. dev_queue_xmit(skb);
  89. }
  90. static inline void dn_rt_finish_output(struct sk_buff *skb, char *dst, char *src)
  91. {
  92. struct net_device *dev = skb->dev;
  93. if ((dev->type != ARPHRD_ETHER) && (dev->type != ARPHRD_LOOPBACK))
  94. dst = NULL;
  95. if (dev_hard_header(skb, dev, ETH_P_DNA_RT, dst, src, skb->len) >= 0)
  96. dn_rt_send(skb);
  97. else
  98. kfree_skb(skb);
  99. }
  100. #endif /* _NET_DN_ROUTE_H */