📄 mibhp.c
字号:
#include "VxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "taskLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "ioLib.h"
#include "fioLib.h"
#include "snmp.h"
#define GDSTATUSID "HP printer"
#define MACADDR "0080123456"
int HPGetVar(VARLIST *vartemp)
{
int temp;
//gdStatusId
static u_char oid1[16] = {0x2b,6,1,4,1,0xb,2,3,9,1,1,7,0,0,0,0};
//npNpiPaeIdentification
static u_char oid2[16] = {0x2b,6,1,4,1,0xb,2,4,3,8,3,3,0,0,0,0};
//npNpiPaeClass
static u_char oid3[16] = {0x2b,6,1,4,1,0xb,2,4,3,8,3,2,0,0,0,0};
//MAC address
static u_char oid4[16] = {0x2b,6,1,4,1,0xb,2,4,3,0xa,7,0,0,0,0,0};
if(memcmp(vartemp->oid,oid1,12) == 0)
{
vartemp->type = TAG_OCTET;
vartemp->value_len = strlen(GDSTATUSID);
vartemp->value = snmpMalloc(vartemp->value_len);
memcpy(vartemp->value,GDSTATUSID,vartemp->value_len);
return OK;
}
if(memcmp(vartemp->oid,oid2,12) == 0)
{
temp = 0;//0=undefined
vartemp->type = TAG_INTERGER;
vartemp->value_len = getLongSize(temp);
temp = (temp << ((4 - vartemp->value_len)<<3));
vartemp->value = snmpMalloc(vartemp->value_len);
memcpy(vartemp->value,&temp,vartemp->value_len);
return OK;
}
if(memcmp(vartemp->oid,oid3,12) == 0)
{
temp = 1;//1= printer,2=plotter,3=instrument,0=undefined
vartemp->type = TAG_INTERGER;
vartemp->value_len = getLongSize(temp);
temp = (temp << ((4 - vartemp->value_len)<<3));
vartemp->value = snmpMalloc(vartemp->value_len);
memcpy(vartemp->value,&temp,vartemp->value_len);
return OK;
}
if(memcmp(vartemp->oid,oid4,11) == 0)
{
vartemp->type = TAG_OCTET;
vartemp->value_len = strlen(MACADDR);
vartemp->value = snmpMalloc(vartemp->value_len);
memcpy(vartemp->value,MACADDR,vartemp->value_len);
return OK;
}
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -