00001
00057 #include "mod.h"
00058
00059 #include "diameter_peer.h"
00060 #include "config.h"
00061 #include "cdp_load.h"
00062
00063 MODULE_VERSION
00064
00065
00066 char* config_file="DiameterPeer.xml";
00068 extern dp_config *config;
00104 static cmd_export_t cdp_cmds[] = {
00105 {"load_cdp", (cmd_function)load_cdp, NO_SCRIPT, 0, 0},
00106
00107 {"AAACreateRequest", (cmd_function)AAACreateRequest, NO_SCRIPT, 0, 0},
00108 {"AAACreateResponse", (cmd_function)AAACreateResponse, NO_SCRIPT, 0, 0},
00109 {"AAAFreeMessage", (cmd_function)AAAFreeMessage, NO_SCRIPT, 0, 0},
00110
00111 {"AAASendMessage", (cmd_function)AAASendMessage, NO_SCRIPT, 0, 0},
00112 {"AAASendMessageToPeer", (cmd_function)AAASendMessageToPeer, NO_SCRIPT, 0, 0},
00113 {"AAASendRecvMessage", (cmd_function)AAASendRecvMessage, NO_SCRIPT, 0, 0},
00114 {"AAASendRecvMessageToPeer", (cmd_function)AAASendRecvMessageToPeer, NO_SCRIPT, 0, 0},
00115
00116
00117 {"AAACreateSession", (cmd_function)AAACreateSession, NO_SCRIPT, 0, 0},
00118 {"AAADropSession", (cmd_function)AAADropSession, NO_SCRIPT, 0, 0},
00119
00120 {"AAACreateTransaction", (cmd_function)AAACreateTransaction, NO_SCRIPT, 0, 0},
00121 {"AAADropTransaction", (cmd_function)AAADropTransaction, NO_SCRIPT, 0, 0},
00122
00123 {"AAACreateAVP", (cmd_function)AAACreateAVP, NO_SCRIPT, 0, 0},
00124 {"AAAAddAVPToMessage", (cmd_function)AAAAddAVPToMessage, NO_SCRIPT, 0, 0},
00125 {"AAAFindMatchingAVP", (cmd_function)AAAFindMatchingAVP, NO_SCRIPT, 0, 0},
00126 {"AAAGetNextAVP", (cmd_function)AAAGetNextAVP, NO_SCRIPT, 0, 0},
00127 {"AAAFreeAVP", (cmd_function)AAAFreeAVP, NO_SCRIPT, 0, 0},
00128 {"AAAGroupAVPS", (cmd_function)AAAGroupAVPS, NO_SCRIPT, 0, 0},
00129 {"AAAUngroupAVPS", (cmd_function)AAAUngroupAVPS, NO_SCRIPT, 0, 0},
00130 {"AAAFindMatchingAVPList", (cmd_function)AAAFindMatchingAVPList, NO_SCRIPT, 0, 0},
00131 {"AAAFreeAVPList", (cmd_function)AAAFreeAVPList, NO_SCRIPT, 0, 0},
00132
00133 {"AAAAddRequestHandler", (cmd_function)AAAAddRequestHandler, NO_SCRIPT, 0, 0},
00134 {"AAAAddResponseHandler", (cmd_function)AAAAddResponseHandler, NO_SCRIPT, 0, 0},
00135
00136 { 0, 0, 0, 0, 0 }
00137 };
00138
00139
00144 static param_export_t cdp_params[] = {
00145 { "config_file",PARAM_STRING,&config_file},
00146 { 0, 0, 0 }
00147 };
00148
00149
00153 struct module_exports exports = {
00154 "cdp",
00155 cdp_cmds,
00156 0,
00157 cdp_params,
00158 cdp_init,
00159 (response_function) 0,
00160 (destroy_function) cdp_exit,
00161 0,
00162 (child_init_function) cdp_child_init
00163 };
00164
00165
00166
00167
00174 static int cdp_init( void )
00175 {
00176 LOG(L_INFO,"INFO:"M_NAME":cdp_init(): CDiameterPeer initializing\n");
00177 if (!diameter_peer_init(config_file)){
00178 LOG(L_CRIT,"ERR:"M_NAME":cdp_init(): error initializing the diameter peer\n");
00179 return 1;
00180 }
00181 register_procs(2+config->workers + 2 * config->peers_cnt);
00182 return 0;
00183 }
00184
00190 static int cdp_child_init( int rank )
00191 {
00192 if (rank == PROC_MAIN) {
00193 LOG(L_INFO,"INFO:"M_NAME":cdp_child_init(): CDiameterPeer starting ...\n");
00194 diameter_peer_start(0);
00195 LOG(L_INFO,"INFO:"M_NAME":cdp_child_init(): ... CDiameterPeer started\n");
00196 }
00197
00198 return 0;
00199 }
00200
00201
00206 static int cdp_exit( void )
00207 {
00208 LOG(L_INFO,"INFO:"M_NAME":cdp_exit(): CDiameterPeer stoping ...\n");
00209 diameter_peer_destroy();
00210 LOG(L_INFO,"INFO:"M_NAME":cdp_exit(): ... CDiameterPeer stoped\n");
00211 return 0;
00212 }
00213
00214
00215
00216
00217