?? rvwpct.c
字號:
* you can add conditions for outgoing msgs
*if (!strcmp(nameBuf, "registrationRequest"))
*/
if (1)
{
int tmp = -1, isString = 0;
int epToken;
int aliasId;
int tokenId;
int tokenParm;
unsigned char md5OID[]= {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05};
int timeSt;
char h323BMP[128];
unsigned char hashInfo[16]; /*"1234567890123456";{
0xd9, 0xba, 0xa9, 0x03, 0xd1, 0x92, 0x5c, 0x69, 0xd9, 0xe8, 0xde, 0x65, 0xbc, 0x82, 0x48, 0x83
};*/
getTime(&timeSt);
/*strcpy(localH323Id, "test");
strcpy(password, "test");
timeSt = 1082366812;*/
PVTADD(hVal, childNodeId, __q931(cryptoTokens), 0, NULL, status);
PVTADD(hVal, status, __q931(CryptoH323Token), 0, NULL, status);
PVTADD(hVal, status, __q931(cryptoEPPwdHash), 0, NULL, epToken);
PVTADD(hVal, epToken, __q931(alias), 0, NULL, aliasId);
String2Bmp(AppParam.localId, h323BMP, strlen(AppParam.localId));
PVTADD(hVal, aliasId, __q931(h323_ID), strlen(AppParam.localId)*2, h323BMP, status);
/*pvtGet(hVal, status, NULL, NULL, &tmp, NULL);
TRACE("timeStamp is %d!\n", tmp);*/
PVTADD(hVal, epToken, __q931(token), 0, NULL, tokenId);
PVTADD(hVal, epToken, __q931(timeStamp), timeSt, NULL, status);
PVTADD(hVal, tokenId, __q931(algorithmOID), sizeof(md5OID), md5OID, status);
PVTADD(hVal, tokenId, __q931(paramS), 0, NULL, tokenParm);
getCleanToken(AppParam.localId, AppParam.password, timeSt, hashInfo);
PVTADD(hVal, tokenId, __q931(hash), 16 * 8, hashInfo, status);
/*pvtGet(hVal, status, NULL, NULL, &tmp, &isString);
TRACE("get hash tmp:%d, isString:%d!\n", tmp, isString);*/
PVTADD(hVal, tokenParm, __q931(null), 0, NULL, status);
break;
}
childNodeId = pvtBrother(hVal, childNodeId);
if (childNodeId < 0)
haveChild = 0;
}
}
/*
void removeEndpointIdFromRRQ(IN int nodeId)
{
int status;
RvPvtNodeId childNodeId;
int keepVal=0;
HPVT hVal = ((cmElem*)hApp)->hVal;
char * msgName = cmGetProtocolMessageName(hApp,nodeId);
if (strcmp(msgName, "registrationRequest") != 0)
{
TRACE("it is not registrationRequest, return\n");
return;
}
status = pvtGetChild(hVal, nodeId, __q931(registrationRequest), &childNodeId);
if (status < 0)
{
TRACE("registrationRequest is not in msg, return %d\n", status);
return;
}
status = pvtGetChild(hVal, childNodeId, __q931(keepAlive), &childNodeId);
if (status < 0)
{
TRACE("keepVal is not in msg, return %d\n", status);
return;
}
status = pvtGet(hVal, childNodeId, NULL, NULL, &keepVal, NULL);
if (status < 0)
{
TRACE("get keepAlive value error, return\n");
return;
}
TRACE("in registrationRequest, keepAlive is %s\n", keepVal ? "on" : "off");
/* if (keepVal == 1)
{
TRACE("not change light RRQ msg, return \n");
return;
}
status = pvtGetChild(hVal, nodeId, __q931(endpointIdentifier), &childNodeId);
if (status < 0)
{
TRACE("get endpointIdentifier return NULL or error, return \n");
return;
}
status = pvtDelete(hVal, childNodeId);
}
*/
RvBool wpGetCapItemValue(int capId, RvInt32* value)
{
/* RvPvtNodeId nodeId;*/
int status;
HPVT hVal = ((cmElem*)hApp)->hVal;
status = pvtGet(hVal, capId, NULL, NULL, value, NULL);
if (status < 0)
{
/* TRACE("get cap item value error\n");*/
return RV_FALSE;
}
return RV_TRUE;
}
RvBool RVCALLCONV wphookSendTo(
IN HPROTCONN hConn,
IN int nodeId,
IN int nodeIdTo,
IN RvBool error)
{
char text[128];
/* format message */
sprintf(text,"New message sent -> %s on %s",
cmGetProtocolMessageName(hApp,nodeId),
cmProtocolGetProtocolName(cmProtocolGetProtocol(hApp,nodeId)));
/* print to log */
/* printTime();*/
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"hook send to {%s}\n", text);
ReleaseSemaphore(fileSem,1,NULL);
}
*/
pvtAddSec(nodeId);
/*
removeEndpointIdFromRRQ(nodeId);
*/
/*TRACE("start print msg:\n");
printRASMsg(nodeId);
pvtPrintStd(((cmElem*)hApp)->hVal, nodeId, -1);
If we're trying to send a URQ - make sure to see if it's partial */
if(!strcmp("unregistrationRequest", cmGetProtocolMessageName(hApp,nodeId)))
{
/*if(atoi(TclGetVariable("tmp(partialURQ)")))
{
/* We need to send a partial URQ only
TclExecute("rgrq:partialURQ %d", nodeId);
}*/
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"rgrq:partialURQ %d\n", nodeId);
ReleaseSemaphore(fileSem,1,NULL);
}
*/
}
return 0;
}
/*
void ChangeIp()
{
char tempIPAddr[32];
ConvertInt2CharNum(tempIPAddr, 0xc0a87b21, 2);
if (ifAddrSet(LOCAL_IF0, tempIPAddr) != OK)
{
TRACE("ChangeIp: Unable to set IP address\n");
}
else
TRACE("ChangeIp: set IP address to 192.168.123.33 OK!\n");
}
*/
extern unsigned char gkEnabled;
extern void SetH323Prop();
#if 0
RvBool ChangeGKCfg(IN void* context)
{
int status;
char buf[128];
char buf1[64];
char newH323Id[] = "testChange";
RvPvtNodeId gkAddrId, h323Id, e164Id;
cmElem* app = (cmElem*)hApp;
GKConnChange* change = (GKConnChange*)context;
if (change->e164 == 0 && change->h323Id == 0 && change->pass == 0)
{
TRACE("e164 and h323Id is not changed, return...\n");
return RV_TRUE;
}
if (!gkEnabled)
{
TRACE("connection mode is P2P, return...\n");
return RV_TRUE;
}
status = cmUnregister(hApp);
if (status < 0)
{
TRACE("unregister return ERROR:%d!\n", status);
return RV_TRUE;
}
h323Id = pvtGetNodeIdByPath(app->hVal, app->rasConf, "registrationInfo.terminalAlias.1.h323-ID");
TRACE("get h323-ID node id is :%d!\n", h323Id);
if (h323Id > 0)
{
status = pvtGetString(app->hVal, h323Id, 64, buf);
if (status > 0)
{
Bmp2String(buf, buf1, status);
TRACE("old h323-ID:%s!\n", buf1);
}
else
{
TRACE("get h323-ID return error!\n");
return RV_TRUE;
}
}
e164Id = pvtGetNodeIdByPath(app->hVal, app->rasConf, "registrationInfo.terminalAlias.2.e164");
TRACE("get e164 node id is :%d!\n", e164Id);
if (e164Id > 0)
{
status = pvtGetString(app->hVal, e164Id, 64, buf);
if (status > 0)
{
TRACE("old e164:%s!\n", buf);
}
else
{
TRACE("get e164 return error!\n");
return RV_TRUE;
}
}
SetH323Prop();
gkEnabled = 1;
if (change->h323Id)
{
String2Bmp(localH323Id, buf, strlen(localH323Id));
status = pvtSet(app->hVal, h323Id, __q931(h323_ID), strlen(localH323Id) * 2, buf);
if (status > 0)
{
TRACE("set h323Id to %s OK!\n", localH323Id);
}
}
if (change->e164)
{
status = pvtSet(app->hVal, e164Id, __q931(e164), strlen(localE164Num), localE164Num);
if (status > 0)
{
TRACE("set e164 to %s OK!\n", localE164Num);
}
}
if (change->pass)
{
strncpy(password, phoneconfig.conf_h323.registerpin, 16);
}
memset(change, 0, sizeof(change));
status = cmRegister(hApp);
if (status < 0)
TRACE("cmRegister return error:%d!\n", status);
/*HCFG hCfg;
status = cmStop(hApp);
if (status < 0)
TRACE("stop stack return error:%d!\n", status);
SetH323Prop();
if (change->gkMode)
{
cmEnd(hApp);
}
InitStack();
configRv();
if ( (hCfg = ciConstruct(bufConfig)) == NULL)
{
TRACE("reconfig stack failed, reboot...\n");
gkEnabled = 0;
reboot_system();
return FALSE;
}
ciDestruct(app->hCfg);
app->hCfg = hCfg;
if(app->rasConf >= 0) { pvtDelete(app->hVal,app->rasConf); app->rasConf = RV_ERROR_UNKNOWN; } app->rasConf=pvtAddRoot(app->hVal,app->synConfRAS,0,NULL); pvtLoadFromConfig(app->hCfg, app->hVal, (char *)"RAS", app->rasConf, &app->logConfig);*/
/*
gkAddrId = pvtGetNodeIdByPath(app->hVal, app->rasConf, "manualDiscovery.defaultGatekeeper.ipAddress.ip");
TRACE("get defaultGateKeeper ip node id is :%d!\n", gkAddrId);
if (gkAddrId > 0)
{
status = pvtGetString(app->hVal, gkAddrId, 32, buf);
if (status > 0)
{
int i;
for (i=0; i < status; i++)
{
TRACE("%02x ", buf[i]);
}
TRACE("\n");
}
else
TRACE("get gk ip return error!\n");
}
h323Id = pvtGetNodeIdByPath(app->hVal, app->rasConf, "registrationInfo.terminalAlias.1.h323-ID");
TRACE("get h323-ID node id is :%d!\n", h323Id);
if (h323Id > 0)
{
status = pvtGetString(app->hVal, h323Id, 64, buf);
if (status > 0)
{
int i;
TRACE("h323-ID:");
for (i=0; i < status; i++)
{
TRACE("%02x ", buf[i]);
}
TRACE("\n");
}
else
TRACE("get h323-ID return error!\n");
}
e164Id = pvtGetNodeIdByPath(app->hVal, app->rasConf, "registrationInfo.terminalAlias.2.e164");
TRACE("get e164 node id is :%d!\n", e164Id);
if (e164Id > 0)
{
status = pvtGetString(app->hVal, e164Id, 64, buf);
if (status > 0)
{
TRACE("e164:%s!\n", buf);
}
else
TRACE("get e164 return error!\n");
}
String2Bmp(newH323Id, buf, strlen(newH323Id));
status = pvtSet(app->hVal, h323Id, __q931(h323_ID), strlen(newH323Id) * 2, buf);
if (status > 0)
{
TRACE("set h323Id to testChange OK!\n");
}
status = pvtSet(app->hVal, e164Id, __q931(e164), strlen("123456"), "123456");
if (status > 0)
{
TRACE("set e163 to 123456 OK!\n");
}
buf[0] = 0xc0;
buf[1] = 0xa8;
buf[2] = 0x7b;
buf[3] = 0x6f;
buf[4] = 0;
status = *(int *)buf;
TRACE("new gk ip:%x!\n", status);
status = pvtSet(app->hVal, gkAddrId, __q931(ip), 4, buf);
if (status > 0)
{
TRACE("set gk ip to 192.168.123.111 OK!\n");
}
status = cmStart(hApp);
if (status < 0)
TRACE("start return error:%d!\n", status);
status = cmRegister(hApp);
if (status < 0)
TRACE("cmRegister return error:%d!\n", status);
*/
return RV_TRUE;
}
#endif
RvBool wpSetH245Tunneling(IN int flag)
{
int status;
RvPvtNodeId tunneling;
cmElem* app = (cmElem*)hApp;
tunneling = pvtGetNodeIdByPath(app->hVal, app->q931Conf, "h245Tunneling");
/* TRACE("get tunneling node id is :%d!\n", tunneling);*/
if (tunneling <= 0)
{
/* TRACE("get tunneling return error:%d!\n", tunneling);*/
}
if (!flag && tunneling > 0)
{
status = pvtDelete(app->hVal, tunneling);
if (status <= 0)
{
/* TRACE("delete tunneling error!\n");*/
return RV_FALSE;
}
/*deleted by mxd 2005.1.20 for windows*/
/* phoneconfig.conf_h323.isH245Tunneling = flag;*/
return RV_TRUE;
}
if (flag && tunneling <= 0)
{
status = pvtAdd(app->hVal, app->q931Conf, __q931(h245Tunneling), flag, NULL, NULL);
if (status > 0)
{
/* TRACE("set h245Tunneling to %d OK!\n", flag);*/
}
else
{
/* TRACE("set h245Tunneling to %d ERROR!\n", flag);*/
}
}
/*deleted by mxd 2005.1.20 for windows*/
/* phoneconfig.conf_h323.isH245Tunneling = flag;*/
return RV_TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -