2
0

iprule.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * netifd - network interface daemon
  3. * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
  4. * Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __IPRULE_H
  16. #define __IPRULE_H
  17. #include "interface-ip.h"
  18. #define IPRULE_PRIORITY_ADDR 10000
  19. #define IPRULE_PRIORITY_ADDR_MASK 20000
  20. #define IPRULE_PRIORITY_NW 90000
  21. #define IPRULE_PRIORITY_REJECT 4200000000
  22. enum iprule_flags {
  23. /* address family for rule */
  24. IPRULE_INET4 = (0 << 0),
  25. IPRULE_INET6 = (1 << 0),
  26. IPRULE_FAMILY = IPRULE_INET4 | IPRULE_INET6,
  27. /* rule specifies input device */
  28. IPRULE_IN = (1 << 2),
  29. /* rule specifies output device */
  30. IPRULE_OUT = (1 << 3),
  31. /* rule specifies src */
  32. IPRULE_SRC = (1 << 4),
  33. /* rule specifies dest */
  34. IPRULE_DEST = (1 << 5),
  35. /* rule specifies priority */
  36. IPRULE_PRIORITY = (1 << 6),
  37. /* rule specifies diffserv/tos */
  38. IPRULE_TOS = (1 << 7),
  39. /* rule specifies fwmark */
  40. IPRULE_FWMARK = (1 << 8),
  41. /* rule specifies fwmask */
  42. IPRULE_FWMASK = (1 << 9),
  43. /* rule performs table lookup */
  44. IPRULE_LOOKUP = (1 << 10),
  45. /* rule performs routing action */
  46. IPRULE_ACTION = (1 << 11),
  47. /* rule is a goto */
  48. IPRULE_GOTO = (1 << 12),
  49. /* rule suppresses results by prefix length */
  50. IPRULE_SUP_PREFIXLEN = (1 << 13),
  51. /* rule specifies uidrange */
  52. IPRULE_UIDRANGE = (1 << 14),
  53. /* rule specifies ipproto */
  54. IPRULE_IPPROTO = (1 << 15),
  55. };
  56. struct iprule {
  57. struct vlist_node node;
  58. unsigned int order;
  59. /* to receive interface events */
  60. struct interface_user in_iface_user;
  61. struct interface_user out_iface_user;
  62. /* device name */
  63. char in_dev[IFNAMSIZ];
  64. char out_dev[IFNAMSIZ];
  65. /* everything below is used as avl tree key */
  66. /* don't change the order */
  67. /* uci interface name */
  68. char *in_iface;
  69. char *out_iface;
  70. enum iprule_flags flags;
  71. bool invert;
  72. unsigned int src_mask;
  73. union if_addr src_addr;
  74. unsigned int dest_mask;
  75. union if_addr dest_addr;
  76. unsigned int priority;
  77. unsigned int tos;
  78. unsigned int fwmark;
  79. unsigned int fwmask;
  80. unsigned int lookup;
  81. unsigned int sup_prefixlen;
  82. unsigned int uidrange_start;
  83. unsigned int uidrange_end;
  84. unsigned int action;
  85. unsigned int gotoid;
  86. unsigned int ipproto;
  87. };
  88. extern struct vlist_tree iprules;
  89. extern const struct uci_blob_param_list rule_attr_list;
  90. void iprule_add(struct blob_attr *attr, bool v6);
  91. void iprule_update_start(void);
  92. void iprule_update_complete(void);
  93. #endif