exp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * netlink/netfilter/exp.h Conntrack Expectation
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  10. * Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
  11. * Copyright (c) 2007 Secure Computing Corporation
  12. * Copyright (c) 2012 Rich Fought <rich.fought@watchguard.com>
  13. */
  14. #ifndef NETLINK_EXP_H_
  15. #define NETLINK_EXP_H_
  16. #include <netlink/netlink.h>
  17. #include <netlink/addr.h>
  18. #include <netlink/cache.h>
  19. #include <netlink/msg.h>
  20. #include <linux/version.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. struct nfnl_exp;
  25. enum nfnl_exp_tuples {
  26. NFNL_EXP_TUPLE_EXPECT,
  27. NFNL_EXP_TUPLE_MASTER,
  28. NFNL_EXP_TUPLE_MASK,
  29. NFNL_EXP_TUPLE_NAT,
  30. NFNL_EXP_TUPLE_MAX
  31. };
  32. extern struct nl_object_ops exp_obj_ops;
  33. extern struct nfnl_exp * nfnl_exp_alloc(void);
  34. extern int nfnl_exp_alloc_cache(struct nl_sock *, struct nl_cache **);
  35. extern int nfnlmsg_exp_group(struct nlmsghdr *);
  36. extern int nfnlmsg_exp_parse(struct nlmsghdr *, struct nfnl_exp **);
  37. extern void nfnl_exp_get(struct nfnl_exp *);
  38. extern void nfnl_exp_put(struct nfnl_exp *);
  39. extern int nfnl_exp_dump_request(struct nl_sock *);
  40. extern int nfnl_exp_build_add_request(const struct nfnl_exp *, int,
  41. struct nl_msg **);
  42. extern int nfnl_exp_add(struct nl_sock *, const struct nfnl_exp *, int);
  43. extern int nfnl_exp_build_delete_request(const struct nfnl_exp *, int,
  44. struct nl_msg **);
  45. extern int nfnl_exp_del(struct nl_sock *, const struct nfnl_exp *, int);
  46. extern int nfnl_exp_build_query_request(const struct nfnl_exp *, int,
  47. struct nl_msg **);
  48. extern int nfnl_exp_query(struct nl_sock *, const struct nfnl_exp *, int);
  49. extern void nfnl_exp_set_family(struct nfnl_exp *, uint8_t);
  50. extern uint8_t nfnl_exp_get_family(const struct nfnl_exp *);
  51. extern void nfnl_exp_set_timeout(struct nfnl_exp *, uint32_t);
  52. extern int nfnl_exp_test_timeout(const struct nfnl_exp *);
  53. extern uint32_t nfnl_exp_get_timeout(const struct nfnl_exp *);
  54. extern void nfnl_exp_set_id(struct nfnl_exp *, uint32_t);
  55. extern int nfnl_exp_test_id(const struct nfnl_exp *);
  56. extern uint32_t nfnl_exp_get_id(const struct nfnl_exp *);
  57. extern int nfnl_exp_set_helper_name(struct nfnl_exp *, void *);
  58. extern int nfnl_exp_test_helper_name(const struct nfnl_exp *);
  59. extern const char * nfnl_exp_get_helper_name(const struct nfnl_exp *);
  60. extern void nfnl_exp_set_zone(struct nfnl_exp *, uint16_t);
  61. extern int nfnl_exp_test_zone(const struct nfnl_exp *);
  62. extern uint16_t nfnl_exp_get_zone(const struct nfnl_exp *);
  63. extern void nfnl_exp_set_flags(struct nfnl_exp *, uint32_t);
  64. extern int nfnl_exp_test_flags(const struct nfnl_exp *);
  65. extern uint32_t nfnl_exp_get_flags(const struct nfnl_exp *);
  66. extern void nfnl_exp_set_class(struct nfnl_exp *, uint32_t);
  67. extern int nfnl_exp_test_class(const struct nfnl_exp *);
  68. extern uint32_t nfnl_exp_get_class(const struct nfnl_exp *);
  69. extern int nfnl_exp_set_fn(struct nfnl_exp *, void *);
  70. extern int nfnl_exp_test_fn(const struct nfnl_exp *);
  71. extern const char * nfnl_exp_get_fn(const struct nfnl_exp *);
  72. extern void nfnl_exp_set_nat_dir(struct nfnl_exp *, uint8_t);
  73. extern int nfnl_exp_test_nat_dir(const struct nfnl_exp *);
  74. extern uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *);
  75. // The int argument specifies which nfnl_exp_dir (expect, master, mask or nat)
  76. // Expectation objects only use orig, not reply
  77. extern int nfnl_exp_set_src(struct nfnl_exp *, int, struct nl_addr *);
  78. extern int nfnl_exp_test_src(const struct nfnl_exp *, int);
  79. extern struct nl_addr * nfnl_exp_get_src(const struct nfnl_exp *, int);
  80. extern int nfnl_exp_set_dst(struct nfnl_exp *, int, struct nl_addr *);
  81. extern int nfnl_exp_test_dst(const struct nfnl_exp *, int);
  82. extern struct nl_addr * nfnl_exp_get_dst(const struct nfnl_exp *, int);
  83. extern void nfnl_exp_set_l4protonum(struct nfnl_exp *, int, uint8_t);
  84. extern int nfnl_exp_test_l4protonum(const struct nfnl_exp *, int);
  85. extern uint8_t nfnl_exp_get_l4protonum(const struct nfnl_exp *, int);
  86. extern void nfnl_exp_set_ports(struct nfnl_exp *, int, uint16_t, uint16_t);
  87. extern int nfnl_exp_test_ports(const struct nfnl_exp *, int);
  88. extern uint16_t nfnl_exp_get_src_port(const struct nfnl_exp *, int);
  89. extern uint16_t nfnl_exp_get_dst_port(const struct nfnl_exp *, int);
  90. extern void nfnl_exp_set_icmp(struct nfnl_exp *, int, uint16_t, uint8_t, uint8_t);
  91. extern int nfnl_exp_test_icmp(const struct nfnl_exp *, int);
  92. extern uint16_t nfnl_exp_get_icmp_id(const struct nfnl_exp *, int);
  93. extern uint8_t nfnl_exp_get_icmp_type(const struct nfnl_exp *, int);
  94. extern uint8_t nfnl_exp_get_icmp_code(const struct nfnl_exp *, int);
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif