configuration.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Copyright (c) 2007, 2008 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. /* Values returned by parse_config_from_string. */
  20. #define CONFIG_ACTION_DONE 0
  21. #define CONFIG_ACTION_QUIT 1
  22. #define CONFIG_ACTION_DUMP 2
  23. #define CONFIG_ACTION_MONITOR 3
  24. #define CONFIG_ACTION_UNMONITOR 4
  25. #define CONFIG_ACTION_NO 5
  26. struct filter_result {
  27. unsigned int add_metric; /* allow = 0, deny = INF, metric = <0..INF> */
  28. unsigned char *src_prefix;
  29. unsigned char src_plen;
  30. unsigned int table;
  31. };
  32. struct filter {
  33. int af;
  34. char *ifname;
  35. unsigned int ifindex;
  36. unsigned char *id;
  37. unsigned char *prefix;
  38. unsigned char plen;
  39. unsigned char plen_ge, plen_le;
  40. unsigned char *src_prefix;
  41. unsigned char src_plen;
  42. unsigned char src_plen_ge, src_plen_le;
  43. unsigned char *neigh;
  44. int proto; /* May be negative */
  45. struct filter_result action;
  46. struct filter *next;
  47. };
  48. extern struct interface_conf *default_interface_conf;
  49. void flush_ifconf(struct interface_conf *if_conf);
  50. int parse_config_from_file(const char *filename, int *line_return);
  51. int parse_config_from_string(char *string, int n, const char **message_return);
  52. void renumber_filters(void);
  53. int input_filter(const unsigned char *id,
  54. const unsigned char *prefix, unsigned short plen,
  55. const unsigned char *src_prefix, unsigned short src_plen,
  56. const unsigned char *neigh, unsigned int ifindex);
  57. int output_filter(const unsigned char *id,
  58. const unsigned char *prefix, unsigned short plen,
  59. const unsigned char *src_prefix, unsigned short src_plen,
  60. unsigned int ifindex);
  61. int redistribute_filter(const unsigned char *prefix, unsigned short plen,
  62. const unsigned char *src_prefix, unsigned short src_plen,
  63. unsigned int ifindex, int proto,
  64. struct filter_result *result);
  65. int install_filter(const unsigned char *prefix, unsigned short plen,
  66. const unsigned char *src_prefix, unsigned short src_plen,
  67. struct filter_result *result);
  68. int finalise_config(void);