digest.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * $Id$
  3. *
  4. * Digest credentials parser interface
  5. *
  6. * Copyright (C) 2001-2003 Fhg Fokus
  7. *
  8. * This file is part of ser, a free SIP server.
  9. *
  10. * ser 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. * For a license to use the ser software under conditions
  16. * other than those described here, or to purchase support for this
  17. * software, please contact iptel.org by e-mail at the following addresses:
  18. * [email protected]
  19. *
  20. * ser is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. */
  29. #ifndef DIGEST_H
  30. #define DIGEST_H
  31. #include "digest_parser.h"
  32. #include "../hf.h" /* struct hdr_field */
  33. #include "../msg_parser.h"
  34. typedef struct auth_body {
  35. /* This is pointer to header field containing
  36. * parsed authorized digest credentials. This
  37. * pointer is set in sip_msg->{authorization,proxy_auth}
  38. * hooks.
  39. *
  40. * This is necessary for functions called after
  41. * {www,proxy}_authorize, these functions need to know
  42. * which credentials are authorized and they will simply
  43. * look into
  44. * sip_msg->{authorization,proxy_auth}->parsed->authorized
  45. */
  46. struct hdr_field* authorized;
  47. dig_cred_t digest; /* Parsed digest credentials */
  48. unsigned char stale; /* Flag is set if nonce is stale */
  49. int nonce_retries; /* How many times the nonce was used */
  50. } auth_body_t;
  51. /*
  52. * Errors returned by check_dig_cred
  53. */
  54. typedef enum dig_err {
  55. E_DIG_OK = 0, /* Everything is OK */
  56. E_DIG_USERNAME = 1, /* Username missing */
  57. E_DIG_REALM = 2, /* Realm missing */
  58. E_DIG_NONCE = 4, /* Nonce value missing */
  59. E_DIG_URI = 8, /* URI missing */
  60. E_DIG_RESPONSE = 16, /* Response missing */
  61. E_DIG_CNONCE = 32, /* CNONCE missing */
  62. E_DIG_NC = 64, /* Nonce-count missing */
  63. } dig_err_t;
  64. /*
  65. * Parse digest credentials
  66. */
  67. int parse_credentials(struct hdr_field* _h);
  68. /*
  69. * Free all memory associated with parsed
  70. * structures
  71. */
  72. void free_credentials(auth_body_t** _b);
  73. /*
  74. * Print dig_cred structure to stdout
  75. */
  76. void print_cred(dig_cred_t* _c);
  77. /*
  78. * Mark credentials as authorized
  79. */
  80. int mark_authorized_cred(struct sip_msg* _m, struct hdr_field* _h);
  81. /*
  82. * Get pointer to authorized credentials
  83. */
  84. int get_authorized_cred(struct hdr_field* _f, struct hdr_field** _h);
  85. /*
  86. * Check if credentials are correct
  87. * (check of semantics)
  88. */
  89. dig_err_t check_dig_cred(dig_cred_t* _c);
  90. #endif /* DIGEST_H */