📄 rvtrapif.c
字号:
#if (0)
******************************************************************************
Filename : rvtrapif.c
Description: trap message send to pipe
******************************************************************************
Copyright (c) 1999 RADVision Inc.
******************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever
without written prior approval by RADVision LTD..
RADVision LTD. reserves the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
******************************************************************************
$Revision:$
$Date:$
$Author:$
******************************************************************************
#endif
#include <stdio.h>
#include "rvlog.h"
#include "rvtrapif.h"
#include "rvsocket.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* socket */
RvSocket rvTrapSocket;
const RvInetPort rvTrapTxPort = 65430;
const RvInetPort rvTrapRxPort = 65431;
/*
* rvSnmpTrapInfoSend( int rvTrapNum, int rvTrapInteger, char *rvTrapString )
* Trap Message format to server: "trap #|integer|string|oidstring"
*/
void rvSnmpTrapMsgSend(RvUint *rvOid, size_t rvOidLen, int trapType,
char * trapMsg, size_t trapMsgLen )
{
char szWriteBuf[512];
char oidtmp[10];
int i;
RvHost host;
RvSocketAddr socketAddr;
char *nl, *start = trapMsg;
sprintf(szWriteBuf, "%d|%d|%d,", trapType, 0, rvOidLen);
for (i = 0; i < (int)rvOidLen; i++ ) {
sprintf(oidtmp, "%d,", *rvOid);
strcat(szWriteBuf, oidtmp);
rvOid++;
}
strcat(szWriteBuf, "|");
/* remove the '\n' in the trapMsg */
while((nl = strchr(start, '\n')) != NULL)
{
*nl = ' ';
start = nl + 1;
}
strcat(szWriteBuf, trapMsg);
if (rvHostConstructLocal(&host) != NULL) {
if (rvSocketAddrConstructInet(&socketAddr, &host, 0, rvTrapTxPort) != NULL)
rvSocketSendTo(&rvTrapSocket, szWriteBuf, strlen(szWriteBuf), &socketAddr) ;
}
}
void rvSnmpTrapSocketInit(void)
{
rvSocketConstructUdp(&rvTrapSocket, rvTrapRxPort);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -