📄 mgc_user.c
字号:
int cid, MegacoMessage_CommandRequest* reqP, MegacoMessage_CommandReplyUnion* repP, Megaco_Status* statusP) { V( ("handle command request %d when MG in state %d\n", reqP->command._d, mgP->state) ); /* This simple example handles noting other than the service change */ switch (reqP->command._d) { case MegacoMessage_CommandChoice_serviceChangeReq: if (mgP->state == MgsConnected) { repP->_d = MegacoMessage_CommandReplyChoice_serviceChangeReply; handle_service_change_req(cid, &reqP->command._u.serviceChange, &repP->_u.serviceChange, statusP); } else { V( ("MG not yet connected\n") ); if (statusP->_d == Megaco_ok) { statusP->_d = Megaco_errorDesc; statusP->_u.desc.code = MEGACO_NOT_IMPLEMENTED; statusP->_u.desc.text._d = TRUE; statusP->_u.desc.text._u.val = "MG not in connected state"; } } break; default: V( ("command %d not implemented\n", reqP->command._d) ); if (statusP->_d == Megaco_ok) { statusP->_d = Megaco_errorDesc; statusP->_u.desc.code = MEGACO_NOT_IMPLEMENTED; statusP->_u.desc.text._d = TRUE; statusP->_u.desc.text._u.val = "Only service change request implemented"; } break; }} static void handle_service_change_req(int cid, MegacoMessage_ServiceChangeRequest* reqP, MegacoMessage_ServiceChangeReply* repP, Megaco_Status* statusP) { V( ("handle service change request\n") ); /* We only support service change on the root termination! */ if (reqP->termIdList._length == 1) { MegacoMessage_TerminationIdUnion* tidP = reqP->termIdList._buffer; if (tidP->_d == MegacoMessage_Encoding_text) { /* text */ char* ttid = *tidP->_u.text.id._buffer; V( ("service change on tid: %s\n", ttid) ); if (strcmp(ttid,"root") == 0) { repP->termIdList = reqP->termIdList; repP->serviceChangeResult._d = MegacoMessage_ServiceChangeResultChoice_serviceChangeResParms; repP->serviceChangeResult._u.serviceChange.mgcId._d = TRUE; repP->serviceChangeResult._u.serviceChange.mgcId._u.val = mid; repP->serviceChangeResult._u.serviceChange.address._d = FALSE; repP->serviceChangeResult._u.serviceChange.version._d = FALSE; repP->serviceChangeResult._u.serviceChange.profile._d = FALSE; repP->serviceChangeResult._u.serviceChange.timeStamp._d = FALSE; } else { V( ("service change only supported for the root termination (%s)\n", ttid) ); if (statusP->_d == Megaco_ok) { statusP->_d = Megaco_errorDesc; statusP->_u.desc.code = MEGACO_NOT_IMPLEMENTED; statusP->_u.desc.text._d = TRUE; statusP->_u.desc.text._u.val = "service change only supported for the root termination (2)"; } } } else { /* binary */ MegacoMessage_BinaryTerminationId* btidP = &tidP->_u.binary; // We don't handle wildcards. Rember this is a simple example... if (btidP->wildcard._length == 0) { int i; for (i = 0 ; i < btidP->id._length ; i++) { V( ("binary termination[%d]: %d\n", i, btidP->id._buffer[i]) ); } } else { V( ("service change only supported for the root (e.g. no wildcards allowed)\n") ); if (statusP->_d == Megaco_ok) { statusP->_d = Megaco_errorDesc; statusP->_u.desc.code = MEGACO_NOT_IMPLEMENTED; statusP->_u.desc.text._d = TRUE; statusP->_u.desc.text._u.val = "service change with wildcards not supported"; } } } } else { if (statusP->_d == Megaco_ok) { statusP->_d = Megaco_errorDesc; statusP->_u.desc.code = MEGACO_NOT_IMPLEMENTED; statusP->_u.desc.text._d = TRUE; statusP->_u.desc.text._u.val = "service change only supported for the root termination (1)"; } }}Megaco_SessionUser_handleTransReply__rs* Megaco_SessionUser_handleTransReply__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, erlang_pid *pid, Megaco_ConnHandle *handle, CORBA_unsigned_short *XXX, Megaco_Status *status, Megaco_ActionReplies *reply, CORBA_Environment *oe_env) { VERBOSE( ("received handleTransReply\n") ); free ((void*)handle); free ((void*)status); free ((void*)reply); return (Megaco_SessionUser_handleTransReply__rs*)NULL;}Megaco_SessionUser_handleTransAck__rs* Megaco_SessionUser_handleTransAck__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, erlang_pid *pid, Megaco_ConnHandle *handle, CORBA_unsigned_short *XXX, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received handleTransAck\n") ); free ((void*)handle); free ((void*)status); return (Megaco_SessionUser_handleTransAck__rs*)NULL;}Megaco_SessionUser_handleUnexpectedTrans__rs* Megaco_SessionUser_handleUnexpectedTrans__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, erlang_pid *pid, Megaco_ConnHandle *handle, CORBA_unsigned_short *XXX, MegacoMessage_TransactionUnion *transaction, CORBA_Environment *oe_env) { VERBOSE( ("received handleUnexpectedTrans\n") ); free ((void*)handle); free ((void*)transaction); return (Megaco_SessionUser_handleUnexpectedTrans__rs*)NULL;}Megaco_SessionUser_systemInfoResponse__rs* Megaco_SessionUser_systemInfoResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, Megaco_SystemInfoValue *info, CORBA_Environment *oe_env) { VERBOSE( ("received systemInfoResponse\n") ); free ((void*)status); free ((void*)info); return (Megaco_SessionUser_systemInfoResponse__rs*)NULL;}Megaco_SessionUser_startUserResponse__rs* Megaco_SessionUser_startUserResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { V( ("received startUserResponse\n") ); ASSERT_OK(status); setup_transport(); free ((void*)status); return (Megaco_SessionUser_startUserResponse__rs*)NULL;} Megaco_SessionUser_stopUserResponse__rs* Megaco_SessionUser_stopUserResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received stopUserResponse\n") ); free ((void*)status); return (Megaco_SessionUser_stopUserResponse__rs*)NULL;}Megaco_SessionUser_userInfoResponse__rs* Megaco_SessionUser_userInfoResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, Megaco_UserInfoValue *info, CORBA_Environment *oe_env) { VERBOSE( ("received userInfoResponse\n") ); free ((void*)status); free ((void*)info); return (Megaco_SessionUser_userInfoResponse__rs*)NULL;}Megaco_SessionUser_updateUserInfoResponse__rs* Megaco_SessionUser_updateUserInfoResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received updateUserInfoResponse\n") ); free ((void*)status); return (Megaco_SessionUser_updateUserInfoResponse__rs*)NULL;}Megaco_SessionUser_connInfoResponse__rs* Megaco_SessionUser_connInfoResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, Megaco_ConnInfoValue *info, CORBA_Environment *oe_env) { VERBOSE( ("received connInfoResponse\n") ); free ((void*)status); free ((void*)info); return (Megaco_SessionUser_connInfoResponse__rs*)NULL;}Megaco_SessionUser_updateConnInfoResponse__rs* Megaco_SessionUser_updateConnInfoResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received updateConnInfoResponse\n") ); free ((void*)status); return (Megaco_SessionUser_updateConnInfoResponse__rs*)NULL;}Megaco_SessionUser_connectResponse__rs* Megaco_SessionUser_connectResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, Megaco_ConnHandle *handle, CORBA_Environment *oe_env) { VERBOSE( ("connectResponse\n") ); free ((void*)status); free ((void*)handle); return (Megaco_SessionUser_connectResponse__rs*)NULL;}Megaco_SessionUser_disconnectResponse__rs* Megaco_SessionUser_disconnectResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received disconnectResponse\n") ); free ((void*)status); return (Megaco_SessionUser_disconnectResponse__rs*)NULL;}Megaco_SessionUser_cancelResponse__rs* Megaco_SessionUser_cancelResponse__cb(Megaco_SessionUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { VERBOSE( ("received cancelResponse\n") ); free ((void*)status); return (Megaco_SessionUser_cancelResponse__rs*)NULL;} /************************************************************ * TCP User Callback Functions ************************************************************/MegacoSessionTcpUser_listenResponse__rs*MegacoSessionTcpUser_listenResponse__cb(MegacoSessionTcpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env) { V( ("received listenResponse\n") ); ASSERT_OK(status); delete_pending(*ref); // Ignore returned data free ((void*)status); return (MegacoSessionTcpUser_listenResponse__rs*)NULL;}MegacoSessionTcpUser_connectResponse__rs* MegacoSessionTcpUser_connectResponse__cb(MegacoSessionTcpUser oe_obj, CORBA_long *ref, Megaco_Status *status, erlang_binary *bin, erlang_pid *pid, CORBA_Environment *oe_env){ VERBOSE( ("received connectResponse\n") ); ASSERT_OK(status); free ((void*)status); free ((void*)bin); return (MegacoSessionTcpUser_connectResponse__rs*)NULL;}MegacoSessionTcpUser_closeResponse__rs* MegacoSessionTcpUser_closeResponse__cb(MegacoSessionTcpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received closeResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionTcpUser_closeResponse__rs*)NULL;}MegacoSessionTcpUser_blockResponse__rs* MegacoSessionTcpUser_blockResponse__cb(MegacoSessionTcpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received blockResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionTcpUser_blockResponse__rs*)NULL;}MegacoSessionTcpUser_unblockResponse__rs* MegacoSessionTcpUser_unblockResponse__cb(MegacoSessionTcpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received unblockResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionTcpUser_unblockResponse__rs*)NULL;}/************************************************************ * UDP User Callback Functions ************************************************************/MegacoSessionUdpUser_openResponse__rs* MegacoSessionUdpUser_openResponse__cb(MegacoSessionUdpUser oe_obj, CORBA_long *ref, Megaco_Status *status, erlang_binary *bin, erlang_pid *pid, CORBA_Environment *oe_env){ V( ("received openResponse\n") ); ASSERT_OK(status); delete_pending(*ref); // Ignore returned data free ((void*)status); free ((void*)bin); return (MegacoSessionUdpUser_openResponse__rs*)NULL;}MegacoSessionUdpUser_closeResponse__rs* MegacoSessionUdpUser_closeResponse__cb(MegacoSessionUdpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received closeResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionUdpUser_closeResponse__rs*)NULL;}MegacoSessionUdpUser_blockResponse__rs* MegacoSessionUdpUser_blockResponse__cb(MegacoSessionUdpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received blockResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionUdpUser_blockResponse__rs*)NULL;}MegacoSessionUdpUser_unblockResponse__rs* MegacoSessionUdpUser_unblockResponse__cb(MegacoSessionUdpUser oe_obj, CORBA_long *ref, Megaco_Status *status, CORBA_Environment *oe_env){ VERBOSE( ("received unblockResponse\n") ); ASSERT_OK(status); free ((void*)status); return (MegacoSessionUdpUser_unblockResponse__rs*)NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -