flow.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. *
  3. * Generic internet FLOW.
  4. *
  5. */
  6. #ifndef _NET_FLOW_H
  7. #define _NET_FLOW_H
  8. #include <linux/in6.h>
  9. #include <asm/atomic.h>
  10. struct flowi {
  11. int oif;
  12. int iif;
  13. union {
  14. struct {
  15. __u32 daddr;
  16. __u32 saddr;
  17. __u32 fwmark;
  18. __u8 tos;
  19. __u8 scope;
  20. } ip4_u;
  21. struct {
  22. struct in6_addr daddr;
  23. struct in6_addr saddr;
  24. __u32 fwmark;
  25. __u32 flowlabel;
  26. } ip6_u;
  27. struct {
  28. __le16 daddr;
  29. __le16 saddr;
  30. __u32 fwmark;
  31. __u8 scope;
  32. } dn_u;
  33. } nl_u;
  34. #define fld_dst nl_u.dn_u.daddr
  35. #define fld_src nl_u.dn_u.saddr
  36. #define fld_fwmark nl_u.dn_u.fwmark
  37. #define fld_scope nl_u.dn_u.scope
  38. #define fl6_dst nl_u.ip6_u.daddr
  39. #define fl6_src nl_u.ip6_u.saddr
  40. #define fl6_fwmark nl_u.ip6_u.fwmark
  41. #define fl6_flowlabel nl_u.ip6_u.flowlabel
  42. #define fl4_dst nl_u.ip4_u.daddr
  43. #define fl4_src nl_u.ip4_u.saddr
  44. #define fl4_fwmark nl_u.ip4_u.fwmark
  45. #define fl4_tos nl_u.ip4_u.tos
  46. #define fl4_scope nl_u.ip4_u.scope
  47. __u8 proto;
  48. __u8 flags;
  49. #define FLOWI_FLAG_MULTIPATHOLDROUTE 0x01
  50. union {
  51. struct {
  52. __u16 sport;
  53. __u16 dport;
  54. } ports;
  55. struct {
  56. __u8 type;
  57. __u8 code;
  58. } icmpt;
  59. struct {
  60. __le16 sport;
  61. __le16 dport;
  62. __u8 objnum;
  63. __u8 objnamel; /* Not 16 bits since max val is 16 */
  64. __u8 objname[16]; /* Not zero terminated */
  65. } dnports;
  66. __u32 spi;
  67. #ifdef CONFIG_IPV6_MIP6
  68. struct {
  69. __u8 type;
  70. } mht;
  71. #endif
  72. } uli_u;
  73. #define fl_ip_sport uli_u.ports.sport
  74. #define fl_ip_dport uli_u.ports.dport
  75. #define fl_icmp_type uli_u.icmpt.type
  76. #define fl_icmp_code uli_u.icmpt.code
  77. #define fl_ipsec_spi uli_u.spi
  78. #ifdef CONFIG_IPV6_MIP6
  79. #define fl_mh_type uli_u.mht.type
  80. #endif
  81. __u32 secid; /* used by xfrm; see secid.txt */
  82. } __attribute__((__aligned__(BITS_PER_LONG/8)));
  83. #define FLOW_DIR_IN 0
  84. #define FLOW_DIR_OUT 1
  85. #define FLOW_DIR_FWD 2
  86. struct sock;
  87. typedef void (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir,
  88. void **objp, atomic_t **obj_refp);
  89. extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
  90. flow_resolve_t resolver);
  91. extern void flow_cache_flush(void);
  92. extern atomic_t flow_cache_genid;
  93. #endif