api.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * $Id$
  3. *
  4. * Functions that operate on IP addresses
  5. *
  6. * Copyright (C) 2012 Hugh Waite (crocodile-rcs.com)
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. */
  25. #ifndef _IPOPS_API_H_
  26. #define _IPOPS_API_H_
  27. #include "../../sr_module.h"
  28. #include "../../parser/msg_parser.h"
  29. typedef int (*compare_ips_f)(const str *const, const str *const);
  30. int ipopsapi_compare_ips(const str *const ip1, const str *const ip2);
  31. typedef int (*ip_is_in_subnet_f)(const str *const, const str *const);
  32. int ipopsapi_ip_is_in_subnet(const str *const ip1, const str *const ip2);
  33. typedef int (*is_ip_f)(const str * const ip);
  34. int ipopsapi_is_ip(const str * const ip);
  35. /**
  36. * @brief IPOPS API structure
  37. */
  38. typedef struct ipops_api {
  39. compare_ips_f compare_ips;
  40. ip_is_in_subnet_f ip_is_in_subnet;
  41. is_ip_f is_ip;
  42. } ipops_api_t;
  43. typedef int (*bind_ipops_f)(ipops_api_t* api);
  44. int bind_ipops(ipops_api_t* api);
  45. /**
  46. * @brief Load the IPOPS API
  47. */
  48. static inline int ipops_load_api(ipops_api_t *api)
  49. {
  50. bind_ipops_f bindipops;
  51. bindipops = (bind_ipops_f)find_export("bind_ipops", 0, 0);
  52. if(bindipops == 0) {
  53. LM_ERR("cannot find bind_ipops\n");
  54. return -1;
  55. }
  56. if (bindipops(api) < 0)
  57. {
  58. LM_ERR("cannot bind ipops api\n");
  59. return -1;
  60. }
  61. return 0;
  62. }
  63. #endif