2
0

api.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 Smile Communications, [email protected]
  5. * Copyright (C) 2012 Smile Communications, [email protected]
  6. *
  7. * The initial version of this code was written by Dragos Vingarzan
  8. * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  9. * Fruanhofer Institute. It was and still is maintained in a separate
  10. * branch of the original SER. We are therefore migrating it to
  11. * Kamailio/SR and look forward to maintaining it from here on out.
  12. * 2011/2012 Smile Communications, Pty. Ltd.
  13. * ported/maintained/improved by
  14. * Jason Penton (jason(dot)penton(at)smilecoms.com and
  15. * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  16. * effort to add full IMS support to Kamailio/SR using a new and
  17. * improved architecture
  18. *
  19. * NB: Alot of this code was originally part of OpenIMSCore,
  20. * FhG Fokus.
  21. * Copyright (C) 2004-2006 FhG Fokus
  22. * Thanks for great work! This is an effort to
  23. * break apart the various CSCF functions into logically separate
  24. * components. We hope this will drive wider use. We also feel
  25. * that in this way the architecture is more complete and thereby easier
  26. * to manage in the Kamailio/SR environment
  27. *
  28. * This file is part of Kamailio, a free SIP server.
  29. *
  30. * Kamailio is free software; you can redistribute it and/or modify
  31. * it under the terms of the GNU General Public License as published by
  32. * the Free Software Foundation; either version 2 of the License, or
  33. * (at your option) any later version
  34. *
  35. * Kamailio is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. * GNU General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU General Public License
  41. * along with this program; if not, write to the Free Software
  42. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  43. *
  44. */
  45. #ifndef _IMS_AUTH_API_H_
  46. #define _IMS_AUTH_API_H_
  47. #include "../../sr_module.h"
  48. #include "../../parser/msg_parser.h"
  49. /**
  50. * return codes to config by auth functions
  51. */
  52. typedef enum auth_cfg_result {
  53. AUTH_RESYNC_REQUESTED = -9, /*!< resync requested from UE via auts param */
  54. AUTH_USER_MISMATCH = -8, /*!< Auth user != From/To user */
  55. AUTH_NONCE_REUSED = -6, /*!< Returned if nonce is used more than once */
  56. AUTH_NO_CREDENTIALS = -5, /*!< Credentials missing */
  57. AUTH_STALE_NONCE = -4, /*!< Stale nonce */
  58. AUTH_USER_UNKNOWN = -3, /*!< User not found */
  59. AUTH_INVALID_PASSWORD = -2, /*!< Invalid password */
  60. AUTH_ERROR = -1, /*!< Error occurred */
  61. AUTH_DROP = 0, /*!< Error, stop config execution */
  62. AUTH_OK = 1 /*!< Success */
  63. } auth_cfg_result_t;
  64. typedef int (*digest_authenticate_f)(struct sip_msg* msg, str *realm,
  65. str *table, hdr_types_t hftype);
  66. /**
  67. * @brief IMS_AUTH API structure
  68. */
  69. typedef struct ims_auth_api {
  70. digest_authenticate_f digest_authenticate;
  71. } ims_auth_api_t;
  72. typedef int (*bind_ims_auth_f)(ims_auth_api_t* api);
  73. /**
  74. * @brief Load the IMS_AUTH API
  75. */
  76. static inline int ims_auth_load_api(ims_auth_api_t *api)
  77. {
  78. bind_ims_auth_f bindauthims;
  79. bindauthims = (bind_ims_auth_f)find_export("bind_ims_auth", 0, 0);
  80. if(bindauthims == 0) {
  81. LM_ERR("cannot find bind_ims_auth\n");
  82. return -1;
  83. }
  84. if (bindauthims(api)==-1)
  85. {
  86. LM_ERR("cannot bind authims api\n");
  87. return -1;
  88. }
  89. return 0;
  90. }
  91. #endif /* _IMS_AUTH_API_H_ */