registration.h

Go to the documentation of this file.
00001 /*
00002  * $Id: registration.h 569 2008-06-24 19:38:57Z vingarzan $
00003  *  
00004  * Copyright (C) 2004-2006 FhG Fokus
00005  *
00006  * This file is part of Open IMS Core - an open source IMS CSCFs & HSS
00007  * implementation
00008  *
00009  * Open IMS Core is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * For a license to use the Open IMS Core software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact Fraunhofer FOKUS by e-mail at the following
00017  * addresses:
00018  *     info@open-ims.org
00019  *
00020  * Open IMS Core is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  * GNU General Public License for more details.
00024  * 
00025  * It has to be noted that this Open Source IMS Core System is not 
00026  * intended to become or act as a product in a commercial context! Its 
00027  * sole purpose is to provide an IMS core reference implementation for 
00028  * IMS technology testing and IMS application prototyping for research 
00029  * purposes, typically performed in IMS test-beds.
00030  * 
00031  * Users of the Open Source IMS Core System have to be aware that IMS
00032  * technology may be subject of patents and licence terms, as being 
00033  * specified within the various IMS-related IETF, ITU-T, ETSI, and 3GPP
00034  * standards. Thus all Open IMS Core users have to take notice of this 
00035  * fact and have to agree to check out carefully before installing, 
00036  * using and extending the Open Source IMS Core System, if related 
00037  * patents and licences may become applicable to the intended usage 
00038  * context.  
00039  *
00040  * You should have received a copy of the GNU General Public License
00041  * along with this program; if not, write to the Free Software
00042  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 /* 3GPP */  
00090     AUTH_AKAV1_MD5          = 1,
00091     AUTH_AKAV2_MD5          = 2,
00092     AUTH_EARLY_IMS          = 3,
00093 /* FOKUS */
00094     AUTH_MD5                = 4,
00095 /* CableLabs */ 
00096     AUTH_DIGEST             = 5,
00097 /* TISPAN */    
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  * Storage of authentication vectors
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_

Generated on Thu Oct 23 04:14:38 2008 for Open IMS Core CSCFs by  doxygen 1.5.2