00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00056 #ifndef S_CSCF_REGISTRATION_H_
00057 #define S_CSCF_REGISTRATION_H_
00058
00059 #include "mod.h"
00060 #include "../../locking.h"
00061
00062 #define NONCE_LEN 16
00063 #define RAND_LEN 16
00064
00065 unsigned char get_algorithm_type(str algorithm);
00066 unsigned char get_auth_scheme_type(str algorithm);
00067
00068 int S_add_path_service_routes(struct sip_msg *msg,char *str1,char *str2 );
00069
00070 int S_add_allow(struct sip_msg *msg,char *str1,char *str2 );
00071
00072 int S_add_service_route(struct sip_msg *msg,char *str1,char *str2 );
00073
00074 int S_add_p_charging_function_addresses(struct sip_msg *msg,char *str1,char *str2 );
00075
00076 int S_check_visited_network_id(struct sip_msg *msg,char *str1,char *str2 );
00077
00078 int S_REGISTER_reply(struct sip_msg *msg, int code, char *text);
00079
00080 int S_is_integrity_protected(struct sip_msg *msg,char *str1,char *str2 );
00081
00082 int S_is_authorized(struct sip_msg *msg,char *str1,char *str2 );
00083
00084 int S_challenge(struct sip_msg *msg,char *str1,char *str2 );
00085
00086
00087 enum authorization_types {
00088 AUTH_UNKNOWN = 0,
00089
00090 AUTH_AKAV1_MD5 = 1,
00091 AUTH_AKAV2_MD5 = 2,
00092 AUTH_EARLY_IMS = 3,
00093
00094 AUTH_MD5 = 4,
00095
00096 AUTH_DIGEST = 5,
00097
00098 AUTH_HTTP_DIGEST_MD5 = 6,
00099 AUTH_NASS_BUNDLED = 7
00100 };
00101
00102 #define AUTH_TYPE_MAX AUTH_NASS_BUNDLED
00103
00105 enum auth_vector_status {
00106 AUTH_VECTOR_UNUSED = 0,
00107 AUTH_VECTOR_SENT = 1,
00108 AUTH_VECTOR_USED = 2,
00109 AUTH_VECTOR_USELESS = 3
00110 } ;
00111
00112
00114 typedef struct _auth_vector {
00115 int item_number;
00116 unsigned char type;
00117 str authenticate;
00118 str authorization;
00119 str ck;
00120 str ik;
00121 time_t expires;
00123 enum auth_vector_status status;
00124 struct _auth_vector *next;
00125 struct _auth_vector *prev;
00126 } auth_vector;
00127
00128
00129
00131 typedef struct _auth_userdata{
00132 unsigned int hash;
00133 str private_identity;
00134 str public_identity;
00135 time_t expires;
00137 auth_vector *head;
00138 auth_vector *tail;
00140 struct _auth_userdata *next;
00141 struct _auth_userdata *prev;
00142 } auth_userdata;
00143
00145 typedef struct {
00146 auth_userdata *head;
00147 auth_userdata *tail;
00148 gen_lock_t *lock;
00149 } auth_hash_slot_t;
00150
00151
00152
00153
00154
00155
00156 int pack_challenge(struct sip_msg *msg,str realm,auth_vector *av);
00157
00158 int S_MAR(struct sip_msg *msg, str public_identity, str private_identity,
00159 int count,str auth_scheme,str nonce,str auts,str server_name,str realm);
00160
00161
00162
00163
00164
00165
00166 inline void auth_data_lock(unsigned int hash);
00167 inline void auth_data_unlock(unsigned int hash);
00168
00169 int auth_data_init(int size);
00170
00171 void auth_data_destroy();
00172
00173 auth_vector *new_auth_vector(int item_number,str auth_scheme,str authenticate,
00174 str authorization,str ck,str ik);
00175 void free_auth_vector(auth_vector *av);
00176
00177 auth_userdata *new_auth_userdata(str private_identity,str public_identity);
00178 void free_auth_userdata(auth_userdata *aud);
00179
00180 inline unsigned int get_hash_auth(str private_identity,str public_identity);
00181
00182 int add_auth_vector(str private_identity,str public_identity,auth_vector *av);
00183 auth_vector* get_auth_vector(str private_identity,str public_identity,int status,str *nonce,unsigned int *hash);
00184
00185 int drop_auth_userdata(str private_identity,str public_identity);
00186
00187 inline void start_reg_await_timer(auth_vector *av);
00188
00189 void reg_await_timer(unsigned int ticks, void* param);
00190
00191
00192
00193 #endif //S_CSCF_REGISTRATION_H_