Mercurial > hg > freeDiameter
view extensions/app_sip/app_sip.h @ 1510:a2fb51309cd2
Add 3GPP TS 29.345 V15.1.0 (2019-09)
Add AVPs:
- App-Layer-User-Id, UTF8String, code 3801, section 6.3.2
- Assistance-info, Grouped, code 3802, section 6.3.3
- Assistance-Info-Validity-Timer, Unsigned32, code 3803, section 6.3.4
- Discovery-Type, Unsigned32, code 3804, section 6.3.5
- Filter-Id, OctetString, code 3805, section 6.3.9
- MAC-Address, UTF8String, code 3806, section 6.3.11
- Match-Report, Grouped, code 3807, section 6.3.12
- Operating-Channel, Unsigned32, code 3808, section 6.3.14
- P2P-Features, Unsigned32, code 3809, section 6.3.15
- ProSe-App-Code, OctetString, code 3810, section 6.3.16
- ProSe-App-Id, UTF8String, code 3811, section 6.3.17
- ProSe-App-Mask, OctetString, code 3812, section 6.3.18
- ProSe-Discovery-Filter, Grouped, code 3813, section 6.3.20
- PRR-Flags, Unsigned32, code 3814, section 6.3.21
- ProSe-Validity-Timer, Unsigned32, code 3815, section 6.3.22
- Requesting-EPUID, UTF8String, code 3816, section 6.3.23
- Targeted-EPUID, UTF8String, code 3817, section 6.3.26
- Time-Window, Unsigned32, code 3818, section 6.3.27
- WiFi-P2P-Assistance-Info, Grouped, code 3819, section 6.3.30
- WLAN-Assistance-Info, Grouped, code 3820, section 6.3.31
- WLAN-Link-Layer-Id, OctetString, code 3821, section 6.3.32
- WLAN-Link-Layer-Id-List, Grouped, code 3822, section 6.3.33
- Location-Update-Trigger, Grouped, code 3823, section 6.3.42
- Location-Update-Event-Type, Unsigned32, code 3824, section 6.3.43
- Change-Of-Area-Type, Grouped, code 3825, section 6.3.44
- Location-Update-Event-Trigger, Unsigned32, code 3826, section 6.3.45
- Report-Cardinality, Enumerated, code 3827, section 6.3.46
- Minimum-Interval-Time, Unsigned32, code 3828, section 6.3.47
- Periodic-Location-Type, Grouped, code 3829, section 6.3.48
- Location-Report-Interval-Time, Unsigned32, code 3830, section 6.3.49
- Total-Number-Of-Reports, Unsigned32, code 3831, section 6.3.50
- Validity-Time-Announce, Unsigned32, code 3832, section 6.3.36
- Validity-Time-Monitor, Unsigned32, code 3833, section 6.3.37
- Validity-Time-Communication, Unsigned32, code 3834, section 6.3.38
- ProSe-App-Code-Info, Grouped, code 3835, section 6.3.39
- MIC, OctetString, code 3836, section 6.3.40
- UTC-based-Counter, Unsigned32, code 3837, section 6.3.41
- ProSe-Match-Refresh-Timer, Unsigned32, code 3838, section 6.3.52
- ProSe-Metadata-Index-Mask, OctetString, code 3839, section 6.3.60
- App-Identifier, Grouped, code 3840, section 6.3.61
- OS-ID, OctetString, code 3841, section 6.3.62
- OS-App-ID, UTF8String, code 3842, section 6.3.63
- Requesting-RPAUID, UTF8String, code 3843, section 6.3.64
- Target-RPAUID, UTF8String, code 3844, section 6.3.65
- Target-PDUID, OctetString, code 3845, section 6.3.66
- ProSe-Restricted-Code, OctetString, code 3846, section 6.3.67
- ProSe-Restricted-Code-Suffix-Range, OctetString, code 3847, section 6.3.68
- Beginning-Suffix, OctetString, code 3848, section 6.3.69
- Ending-Suffix, OctetString, code 3849, section 6.3.70
- Discovery-Entry-ID, Unsigned32, code 3850, section 6.3.59
- Match-Timestamp, Time, code 3851, section 6.3.71
- PMR-Flags, Unsigned32, code 3852, section 6.3.57
- ProSe-Application-Metadata, UTF8String, code 3853, section 6.3.58
- Discovery-Auth-Request, Grouped, code 3854, section 6.3.53
- Discovery-Auth-Response, Grouped, code 3855, section 6.3.54
- Match-Request, Grouped, code 3856, section 6.3.55
- Match-Report-Info, Grouped, code 3857, section 6.3.56
- Banned-RPAUID, UTF8String, code 3858, section 6.3.73
- Banned-PDUID, OctetString, code 3859, section 6.3.74
- Code-Receiving-Security-Material, Grouped, code 3860, section 6.3.75
- Code-Sending-Security-Material, Grouped, code 3861, section 6.3.76
- DUSK, OctetString, code 3862, section 6.3.77
- DUIK, OctetString, code 3863, section 6.3.78
- DUCK, OctetString, code 3864, section 6.3.79
- MIC-Check-indicator, Unsigned32, code 3865, section 6.3.80
- Encrypted-Bitmask, OctetString, code 3866, section 6.3.81
- ProSe-App-Code-Suffix-Range, OctetString, code 3867, section 6.3.82
- PC5-tech, OctetString, code 3868, section 6.3.84
Note: Name conflict with 3GPP TS 29.154 Time-Window (4204).
Time-Window (3818) in 3GPP TS 29.345 V12.1.0 (2014-12) predates
Time-Window (4204) in 3GPP TS 29.154 V13.1.0 (2016-03).
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Sun, 05 Apr 2020 08:27:37 +1000 |
parents | c8057892e56b |
children |
line wrap: on
line source
/********************************************************************************************************* * Software License Agreement (BSD License) * * Author: Alexandre Westfahl <awestfahl@freesipserver.net> * * * * Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project. * * * * All rights reserved. * * * * Redistribution and use of this software in source and binary forms, with or without modification, are * * permitted provided that the following conditions are met: * * * * * Redistributions of source code must retain the above * * copyright notice, this list of conditions and the * * following disclaimer. * * * * * Redistributions in binary form must reproduce the above * * copyright notice, this list of conditions and the * * following disclaimer in the documentation and/or other * * materials provided with the distribution. * * * * * Neither the name of the Teraoka Laboratory nor the * * names of its contributors may be used to endorse or * * promote products derived from this software without * * specific prior written permission of Teraoka Laboratory * * * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *********************************************************************************************************/ #include <freeDiameter/extension.h> #include <sys/time.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> GCC_DIAG_OFF("-Wdeprecated-declarations") #include <gcrypt.h> GCC_DIAG_ON("-Wdeprecated-declarations") #include <string.h> #include <mysql.h> #include "md5.h" #define NONCE_SIZE 16 #define DIGEST_LEN 16 /* Mode for the extension */ #define MODE_DSSERVER 0x1 #define MODE_SL 0x2 //Redirect_Host_Usage #define ALL_USER 6 /* The module configuration */ struct as_conf { int mode; /* default MODE_DSSERVER | MODE_SL */ enum {ASMYSQL} datasource; char * mysql_login; char * mysql_password; char * mysql_database; char * mysql_server; char mysql_prefix[10]; //default: as_ uint16_t mysql_port; //if 0, default port will be used uint16_t rtr_port; uint16_t ppr_port; }; extern struct as_conf * as_conf; /* Parse the configuration file */ int as_conf_handle(char * conffile); extern MYSQL *conn; void calc_md5(char *buffer, char * data); void clear_digest(uint8_t * digest, char * readable_digest, int digestlength); struct avp_hdr * walk_digest(struct avp *avp, int avp_code); //MySQL part int start_mysql_connection(); void request_mysql(char *query); void close_mysql_connection(); int get_sipserver_uri(const unsigned char *sip_aor, const size_t sipaorlen, unsigned char ** sipserver_uri, size_t *sipserverurilen); int exist_username(const unsigned char *sip_aor, const size_t sipaorlen); int get_sipserver_cap(const unsigned char *sip_aor, const size_t sipaorlen, struct avp **capabilities); int get_password(const unsigned char *username, const size_t usernamelen, char *password); int check_sipaor(const unsigned char *username, const size_t usernamelen, const char * sip_aor,const size_t sipaorlen); int add_user_datatype(const unsigned char *sip_aor, const size_t sipaorlen,struct msg *message); int set_pending_flag(const unsigned char *username, const size_t usernamelen); int clear_pending_flag(const unsigned char *username, const size_t usernamelen); int set_real_sipserver_uri(const unsigned char *username, const size_t usernamelen, const unsigned char *sipserver_uri,const size_t sipserverurilen); int set_sipserver_uri(const unsigned char *username, const size_t usernamelen, const unsigned char *sipserver_uri,const size_t sipserverurilen); //int get_sipserver_uri(const unsigned char *sip_aor, const size_t sipaorlen, unsigned char ** sipserver_uri, size_t *sipserverurilen); int allow_roaming(const unsigned char *username, const size_t usernamelen, const char * network,const size_t networklen); int get_diameter_uri(const unsigned char *sip_aor, const size_t sipaorlen, char ** diameter_uri, size_t *diameterurilen); //count functions int count_avp(struct msg * message, int code, int vendor); void DigestCalcHA1(char * pszAlg,char * pszUserName,char * pszRealm,char * pszPassword,char * pszNonce,char * pszCNonce,HASHHEX SessionKey); void DigestCalcResponse(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); void DigestCalcResponseAuth(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); //thread procedure void *rtr_socket(void *); void *ppr_socket(void *); struct rtrsipaor { char username[200]; char sip_aor1[200]; char sip_aor2[200]; char sip_aor3[200]; char strreason[200]; char desthost[200]; int reason; }; struct pprsipaor { char username[200]; char datatype1[255]; char datatype2[255]; char datatype3[255]; int accounting; }; int app_sip_RTR_cb(struct rtrsipaor *structure); int app_sip_PPR_cb(struct pprsipaor *structure); int ds_entry(); void fd_ext_fini(void); int app_sip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_MAR_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_RTA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_PPA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_LIR_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_UAR_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); int app_sip_SAR_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); //Suscriber Locator int app_sip_SL_LIR_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act); //int app_sip_SL_SAR_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act); #define SQL_GETPASSWORD "SELECT `password` FROM ds_users WHERE `username` ='%s'" #define SQL_GETPASSWORD_LEN sizeof(SQL_GETPASSWORD)-2 //username by SIP-AOR #define SQL_GETUSERNAME "SELECT `username` FROM ds_users, ds_sip_aor WHERE `sip_aor` ='%s' AND `ds_sip_aor`.`id_user` = `ds_users`.`id_user`" #define SQL_GETUSERNAME_LEN sizeof(SQL_GETUSERNAME)-2 //sip server uri by username #define SQL_GETSIPURI "SELECT `sip_server_uri` FROM ds_users WHERE `username` ='%s'" #define SQL_GETSIPURI_LEN sizeof(SQL_GETSIPURI)-2 //sip server uri by SIP-AOR #define SQL_GETSIPSERURI "SELECT `ds_sip_aor`.`sip_server_uri` FROM ds_users, ds_sip_aor WHERE `sip_aor` ='%s' AND `ds_sip_aor`.`id_user` = `ds_users`.`id_user`" #define SQL_GETSIPSERURI_LEN sizeof(SQL_GETSIPSERURI)-2 //sip capabilities for a SIP-AOR #define SQL_GETSIPSERCAP "SELECT `compulsory`,`id_service` FROM ds_user_services, ds_sip_aor WHERE `sip_aor` ='%s' AND `ds_sip_aor`.`id_user` = `ds_user_services`.`id_user`" #define SQL_GETSIPSERCAP_LEN sizeof(SQL_GETSIPSERCAP)-2 //user data for a user data supported #define SQL_GETSIPDATA "SELECT `label_type`,`data` FROM ds_sip_aor, ds_user_data, ds_data_types WHERE `sip_aor` ='%s' AND `ds_sip_aor`.`id_sip_aor` = `ds_user_data`.`id_sip_aor` AND `ds_data_types`.`id_data_type`=`ds_user_data`.`id_data_type`" #define SQL_GETSIPDATA_LEN sizeof(SQL_GETSIPDATA)-2 #define SQL_GETDIAMURI "SELECT `sipserver_uri` FROM ds_sip_aor_map WHERE `sip_aor` ='%s'" #define SQL_GETDIAMURI_LEN sizeof(SQL_GETDIAMURI)-2 //networks for this user #define SQL_GETUSERNET "SELECT `label_network` FROM ds_users, ds_user_networks, ds_networks WHERE `ds_users`.`username` ='%s' AND `ds_user_networks`.`id_user` = `ds_users`.`id_user` AND `ds_user_networks`.`id_network` = `ds_networks`.`id_network`" #define SQL_GETUSERNET_LEN sizeof(SQL_GETUSERNET)-2 #define SQL_SETSIPURI "UPDATE ds_users SET `temp_sip_server_uri`='%s' WHERE `username` ='%s'" #define SQL_SETSIPURI_LEN sizeof(SQL_SETSIPURI)-4 //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO #define SQL_RMSIPURI "UPDATE ds_users SET `temp_sip_server_uri`='', `sip_server_uri`='' WHERE `id_user` ='%s'" #define SQL_RMSIPURI_LEN sizeof(SQL_RMSIPURI)-2 //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO #define SQL_SETREALSIPURI "UPDATE ds_users SET `sip_server_uri`='%s' WHERE `username` ='%s'" #define SQL_SETREALSIPURI_LEN sizeof(SQL_SETREALSIPURI)-4 #define SQL_SETFLAG "UPDATE ds_users SET `authentication_pending`=1 WHERE `username` ='%s'" #define SQL_SETFLAG_LEN sizeof(SQL_SETFLAG)-2 #define SQL_CLEARFLAG "UPDATE ds_users SET `authentication_pending`=0, `registrated`=1 WHERE `username` ='%s'" #define SQL_CLEARFLAG_LEN sizeof(SQL_CLEARFLAG)-2 #define SQL_GETSIPAOR "SELECT `sip_aor` FROM `ds_sip_aor`, `ds_users` WHERE `ds_sip_aor`.`id_user` = `ds_users`.`id_user` AND `ds_users`.`username` = '%s'" #define SQL_GETSIPAOR_LEN sizeof(SQL_GETSIPAOR)-2 //#define SQL_CLEARFLAG "UPDATE ds_users SET `authentication_pending`=0 WHERE `username` ='%s'" //#define SQL_CLEARFLAG_LEN 67 extern struct session_handler * ds_sess_hdl; //AVP code #define CODE_SIP_USER_DATA_TYPE 388 #define CODE_SIP_AOR 122 //Storage for some useful AVPs struct app_sip_dict{ struct dict_object * Auth_Session_State; struct dict_object * Auth_Application_Id; struct dict_object * Destination_Host; struct dict_object * Destination_Realm; struct dict_object * User_Name; struct dict_object * Session_Id; struct dict_object * Redirect_Host; struct dict_object * Redirect_Host_Usage; struct dict_object * SIP_Auth_Data_Item; struct dict_object * SIP_Accounting_Information; struct dict_object * SIP_Accounting_Server_URI; struct dict_object * SIP_Credit_Control_Server_URI; struct dict_object * SIP_Server_Assignment_Type; struct dict_object * SIP_Item_Number; struct dict_object * SIP_User_Authorization_Type; struct dict_object * SIP_Supported_User_Data_Type; struct dict_object * SIP_User_Data; struct dict_object * SIP_User_Data_Type; struct dict_object * SIP_User_Data_Contents; struct dict_object * SIP_User_Data_Already_Available; struct dict_object * SIP_Visited_Network_Id; struct dict_object * SIP_Authorization; struct dict_object * SIP_Authenticate; struct dict_object * SIP_Number_Auth_Items; struct dict_object * SIP_Authentication_Scheme; struct dict_object * SIP_Authentication_Info; struct dict_object * SIP_Server_URI; struct dict_object * SIP_Server_Capabilities; struct dict_object * SIP_Mandatory_Capability; struct dict_object * SIP_Optional_Capability; struct dict_object * SIP_Method; struct dict_object * SIP_AOR; struct dict_object * SIP_Deregistration_Reason; struct dict_object * SIP_Reason_Code; struct dict_object * SIP_Reason_Info; struct dict_object * Digest_URI; struct dict_object * Digest_Nonce; struct dict_object * Digest_Nonce_Count; struct dict_object * Digest_CNonce; struct dict_object * Digest_Realm; struct dict_object * Digest_Response; struct dict_object * Digest_Response_Auth; struct dict_object * Digest_Username; struct dict_object * Digest_Method; struct dict_object * Digest_QOP; struct dict_object * Digest_Algorithm; struct dict_object * Digest_HA1; }; extern struct app_sip_dict sip_dict;