Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | /********************************************************************************************************* |
| 2 | * Software License Agreement (BSD License) * |
| 3 | * Author: Alexandre Westfahl <awestfahl@freediameter.net> * |
| 4 | * * |
| 5 | * Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project. * |
| 6 | * * |
| 7 | * All rights reserved. * |
| 8 | * * |
| 9 | * Redistribution and use of this software in source and binary forms, with or without modification, are * |
| 10 | * permitted provided that the following conditions are met: * |
| 11 | * * |
| 12 | * * Redistributions of source code must retain the above * |
| 13 | * copyright notice, this list of conditions and the * |
| 14 | * following disclaimer. * |
| 15 | * * |
| 16 | * * Redistributions in binary form must reproduce the above * |
| 17 | * copyright notice, this list of conditions and the * |
| 18 | * following disclaimer in the documentation and/or other * |
| 19 | * materials provided with the distribution. * |
| 20 | * * |
| 21 | * * Neither the name of the Teraoka Laboratory nor the * |
| 22 | * names of its contributors may be used to endorse or * |
| 23 | * promote products derived from this software without * |
| 24 | * specific prior written permission of Teraoka Laboratory * |
| 25 | * * |
| 26 | * * |
| 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
| 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
| 29 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
| 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
| 31 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
| 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
| 33 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
| 34 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
| 35 | *********************************************************************************************************/ |
| 36 | #include <freeDiameter/extension.h> |
| 37 | #include <sys/time.h> |
| 38 | #include <stdint.h> |
| 39 | #include <stdlib.h> |
| 40 | #include <stdio.h> |
| 41 | GCC_DIAG_OFF("-Wdeprecated-declarations") |
| 42 | #include <gcrypt.h> |
| 43 | GCC_DIAG_ON("-Wdeprecated-declarations") |
| 44 | #include <string.h> |
| 45 | #include <mysql.h> |
| 46 | |
| 47 | /* The module configuration */ |
| 48 | struct ts_conf { |
| 49 | char * destination_sip; |
| 50 | char * destination_realm; |
| 51 | char * username; |
| 52 | char * password; |
| 53 | char * sip_aor; |
| 54 | }; |
| 55 | extern struct ts_conf * ts_conf; |
| 56 | |
| 57 | //Storage for some useful AVPs |
| 58 | struct sip_dict{ |
| 59 | struct dict_object * Auth_Session_State; |
| 60 | struct dict_object * Auth_Application_Id; |
| 61 | struct dict_object * Destination_Host; |
| 62 | struct dict_object * User_Name; |
| 63 | struct dict_object * Session_Id; |
| 64 | struct dict_object * Redirect_Host; |
| 65 | struct dict_object * Redirect_Host_Usage; |
| 66 | struct dict_object * SIP_Auth_Data_Item; |
| 67 | struct dict_object * SIP_Accounting_Information; |
| 68 | struct dict_object * SIP_Accounting_Server_URI; |
| 69 | struct dict_object * SIP_Credit_Control_Server_URI; |
| 70 | struct dict_object * SIP_Server_Assignment_Type; |
| 71 | struct dict_object * SIP_Item_Number; |
| 72 | struct dict_object * SIP_User_Authorization_Type; |
| 73 | struct dict_object * SIP_Supported_User_Data_Type; |
| 74 | struct dict_object * SIP_User_Data; |
| 75 | struct dict_object * SIP_User_Data_Type; |
| 76 | struct dict_object * SIP_User_Data_Contents; |
| 77 | struct dict_object * SIP_User_Data_Already_Available; |
| 78 | struct dict_object * SIP_Visited_Network_Id; |
| 79 | struct dict_object * SIP_Authorization; |
| 80 | struct dict_object * SIP_Authenticate; |
| 81 | struct dict_object * SIP_Number_Auth_Items; |
| 82 | struct dict_object * SIP_Authentication_Scheme; |
| 83 | struct dict_object * SIP_Authentication_Info; |
| 84 | struct dict_object * SIP_Server_URI; |
| 85 | struct dict_object * SIP_Server_Capabilities; |
| 86 | struct dict_object * SIP_Mandatory_Capability; |
| 87 | struct dict_object * SIP_Optional_Capability; |
| 88 | struct dict_object * SIP_Method; |
| 89 | struct dict_object * SIP_AOR; |
| 90 | struct dict_object * SIP_Deregistration_Reason; |
| 91 | struct dict_object * SIP_Reason_Code; |
| 92 | struct dict_object * SIP_Reason_Info; |
| 93 | struct dict_object * Digest_URI; |
| 94 | struct dict_object * Digest_Nonce; |
| 95 | struct dict_object * Digest_Nonce_Count; |
| 96 | struct dict_object * Digest_CNonce; |
| 97 | struct dict_object * Digest_Realm; |
| 98 | struct dict_object * Digest_Response; |
| 99 | struct dict_object * Digest_Response_Auth; |
| 100 | struct dict_object * Digest_Username; |
| 101 | struct dict_object * Digest_Method; |
| 102 | struct dict_object * Digest_QOP; |
| 103 | struct dict_object * Digest_Algorithm; |
| 104 | struct dict_object * Digest_HA1; |
| 105 | struct dict_object * Destination_Realm; |
| 106 | }; |
| 107 | |
| 108 | extern struct sip_dict sip_dict; |
| 109 | extern struct session_handler * ts_sess_hdl; |
| 110 | |
| 111 | int ts_entry(); |
| 112 | void fd_ext_fini(void); |
| 113 | |
| 114 | int test_sip_LIR_cb(); |
| 115 | int test_sip_UAR_cb(); |
| 116 | int test_sip_SAR_cb(); |
| 117 | int test_sipSL_LIR_cb(); |
| 118 | |
| 119 | int test_sip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 120 | int test_sip_MAA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 121 | int test_sip_RTR_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 122 | int test_sip_UAA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 123 | int test_sip_LIA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 124 | int test_sip_SAA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |
| 125 | int test_sipSL_LIA_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act); |