00001 /* 00002 * $Id: digest.h 4518 2008-07-28 15:39:28Z henningw $ 00003 * 00004 * Digest credentials parser interface 00005 * 00006 * Copyright (C) 2001-2003 FhG Fokus 00007 * 00008 * This file is part of Kamailio, a free SIP server. 00009 * 00010 * Kamailio is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version 00014 * 00015 * Kamailio is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 00025 00026 #ifndef DIGEST_H 00027 #define DIGEST_H 00028 00029 #include "digest_parser.h" 00030 #include "../hf.h" /* struct hdr_field */ 00031 #include "../msg_parser.h" 00032 00033 00034 typedef struct auth_body { 00035 /* This is pointer to header field containing 00036 * parsed authorized digest credentials. This 00037 * pointer is set in sip_msg->{authorization,proxy_auth} 00038 * hooks. 00039 * 00040 * This is necessary for functions called after 00041 * {www,proxy}_authorize, these functions need to know 00042 * which credentials are authorized and they will simply 00043 * look into 00044 * sip_msg->{authorization,proxy_auth}->parsed->authorized 00045 */ 00046 struct hdr_field* authorized; 00047 dig_cred_t digest; /* Parsed digest credentials */ 00048 unsigned char stale; /* Flag is set if nonce is stale */ 00049 } auth_body_t; 00050 00051 00052 /* 00053 * Errors returned by check_dig_cred 00054 */ 00055 typedef enum dig_err { 00056 E_DIG_OK = 0, /* Everything is OK */ 00057 E_DIG_USERNAME = 1, /* Username missing */ 00058 E_DIG_REALM = 2, /* Realm missing */ 00059 E_DIG_NONCE = 4, /* Nonce value missing */ 00060 E_DIG_URI = 8, /* URI missing */ 00061 E_DIG_RESPONSE = 16, /* Response missing */ 00062 E_DIG_CNONCE = 32, /* CNONCE missing */ 00063 E_DIG_NC = 64, /* Nonce-count missing */ 00064 E_DIG_DOMAIN = 128 /* Username domain != realm */ 00065 } dig_err_t; 00066 00067 00068 /* 00069 * Parse digest credentials 00070 */ 00071 int parse_credentials(struct hdr_field* _h); 00072 00073 00074 /* 00075 * Free all memory associated with parsed 00076 * structures 00077 */ 00078 void free_credentials(auth_body_t** _b); 00079 00080 00081 /* 00082 * Print dig_cred structure to stdout 00083 */ 00084 void print_cred(dig_cred_t* _c); 00085 00086 00087 /* 00088 * Mark credentials as authorized 00089 */ 00090 int mark_authorized_cred(struct sip_msg* _m, struct hdr_field* _h); 00091 00092 00093 /* 00094 * Get pointer to authorized credentials 00095 */ 00096 int get_authorized_cred(struct hdr_field* _f, struct hdr_field** _h); 00097 00098 00099 /* 00100 * Check if credentials are correct 00101 * (check of semantics) 00102 */ 00103 dig_err_t check_dig_cred(dig_cred_t* _c); 00104 00105 00106 #endif /* DIGEST_H */
1.5.6