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 #include "../../sr_module.h"
00041 #include "../../mem/mem.h"
00042 #include "../../config.h"
00043 #include "../../radius.h"
00044 #include "verify.h"
00045
00046 MODULE_VERSION
00047
00048 struct attr attrs[A_MAX];
00049 struct val vals[V_MAX];
00050 void *rh;
00051
00052 static int mod_init(void);
00053
00054
00055
00056
00057
00058 static char* radius_config = DEFAULT_RADIUSCLIENT_CONF;
00059 int verify_destination_service_type = -1;
00060 int verify_source_service_type = -1;
00061
00062
00063
00064
00065 static cmd_export_t cmds[] = {
00066 {"verify_destination", (cmd_function)verify_destination, 0, 0, 0,
00067 REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
00068 {"verify_source", (cmd_function)verify_source, 0, 0, 0,
00069 REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
00070 {0, 0, 0, 0, 0, 0}
00071 };
00072
00073
00074
00075
00076
00077 static param_export_t params[] = {
00078 {"radius_config", STR_PARAM, &radius_config},
00079 {"verify_destination_service_type", INT_PARAM,
00080 &verify_destination_service_type},
00081 {"verify_source_service_type", INT_PARAM,
00082 &verify_source_service_type},
00083 {0, 0, 0}
00084 };
00085
00086
00087
00088
00089
00090 struct module_exports exports = {
00091 "peering",
00092 DEFAULT_DLFLAGS,
00093 cmds,
00094 params,
00095 0,
00096 0,
00097 0,
00098 0,
00099 mod_init,
00100 0,
00101 0,
00102 0
00103 };
00104
00105
00106
00107
00108
00109 static int mod_init(void)
00110 {
00111 memset(attrs, 0, sizeof(attrs));
00112 memset(vals, 0, sizeof(vals));
00113 attrs[A_USER_NAME].n = "User-Name";
00114 attrs[A_SIP_URI_USER].n = "SIP-URI-User";
00115 attrs[A_SIP_FROM_TAG].n = "SIP-From-Tag";
00116 attrs[A_SIP_CALL_ID].n = "SIP-Call-Id";
00117 attrs[A_SIP_REQUEST_HASH].n = "SIP-Request-Hash";
00118 attrs[A_SIP_AVP].n = "SIP-AVP";
00119 attrs[A_SERVICE_TYPE].n = "Service-Type";
00120 vals[V_SIP_VERIFY_DESTINATION].n = "Sip-Verify-Destination";
00121 vals[V_SIP_VERIFY_SOURCE].n = "Sip-Verify-Source";
00122
00123 if ((rh = rc_read_config(radius_config)) == NULL) {
00124 LM_ERR("error opening configuration file\n");
00125 return -1;
00126 }
00127
00128 if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
00129 LM_ERR("error opening dictionary file\n");
00130 return -2;
00131 }
00132
00133 INIT_AV(rh, attrs, A_MAX, vals, V_MAX, "peering", -3, -4);
00134
00135 if (verify_destination_service_type != -1) {
00136 vals[V_SIP_VERIFY_DESTINATION].v =
00137 verify_destination_service_type;
00138 }
00139
00140 if (verify_source_service_type != -1) {
00141 vals[V_SIP_VERIFY_SOURCE].v = verify_source_service_type;
00142 }
00143
00144 return 0;
00145 }