📄 sipua.c
字号:
/* This file was generated by mib2c and is intended for use as a mib module for the ucd-snmp snmpd agent. *//* This should always be included first before anything else */#include <config.h>/* minimal include directives */#include "mibincl.h"#include "util_funcs.h"#include "sipUA.h"/* * sipUA_variables_oid: * this is the top level oid that we want to register under. This * is essentially a prefix, with the suffix appearing in the * variable below. */oid sipUA_variables_oid[] = { 1,3,6,1,4,1,5738,3,42,1,2 };/* * variable4 sipUA_variables: * this variable defines function callbacks and type return information * for the sipUA mib section */struct variable4 sipUA_variables[] = {/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */#define SIPUACFGTIMERTRYING 1 { SIPUACFGTIMERTRYING , ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,1,1 } },#define SIPUACFGTIMEREXPIRES 2 { SIPUACFGTIMEREXPIRES, ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,1,2 } },#define SIPUACFGTIMERCONNECT 3 { SIPUACFGTIMERCONNECT, ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,1,3 } },#define SIPUACFGTIMERDISCONNECT 4 { SIPUACFGTIMERDISCONNECT, ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,1,4 } },#define SIPUACFGRETRYINVITE 5 { SIPUACFGRETRYINVITE , ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,2,1 } },#define SIPUACFGRETRYBYE 6 { SIPUACFGRETRYBYE , ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,2,2 } },#define SIPUACFGRETRYCANCEL 7 { SIPUACFGRETRYCANCEL , ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,2,3 } },#define SIPUACFGRETRYREGISTER 8 { SIPUACFGRETRYREGISTER, ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,2,4 } },#define SIPUACFGRETRYRESPONSE 9 { SIPUACFGRETRYRESPONSE, ASN_INTEGER , RWRITE, var_sipUA, 3, { 1,2,5 } },#define SIPSTATSRETRYINVITES 10 { SIPSTATSRETRYINVITES, ASN_COUNTER , RONLY , var_sipUA, 3, { 2,1,1 } },#define SIPSTATSRETRYBYES 11 { SIPSTATSRETRYBYES , ASN_COUNTER , RONLY , var_sipUA, 3, { 2,1,2 } },#define SIPSTATSRETRYCANCELS 12 { SIPSTATSRETRYCANCELS, ASN_COUNTER , RONLY , var_sipUA, 3, { 2,1,3 } },#define SIPSTATSRETRYREGISTERS 13 { SIPSTATSRETRYREGISTERS, ASN_COUNTER , RONLY , var_sipUA, 3, { 2,1,4 } },#define SIPSTATSRETRYRESPONSES 14 { SIPSTATSRETRYRESPONSES, ASN_COUNTER , RONLY , var_sipUA, 3, { 2,1,5 } },};/* (L = length of the oidsuffix) *//* * init_sipUA(): * Initialization routine. This is called when the agent starts up. * At a minimum, registration of your variables should take place here. */void init_sipUA(void) { /* register ourselves with the agent to handle our mib tree */ REGISTER_MIB("sipUA", sipUA_variables, variable4, sipUA_variables_oid); /* place any other initialization junk you need here */}/* * var_sipUA(): * This function is called every time the agent gets a request for * a scalar variable that might be found within your mib section * registered above. It is up to you to do the right thing and * return the correct value. * You should also correct the value of "var_len" if necessary. * * Please see the documentation for more information about writing * module extensions, and check out the examples in the examples * and mibII directories. */unsigned char *var_sipUA(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method){ /* variables we may use later */ static long long_ret; static unsigned char string[SPRINT_MAX_LEN]; static oid objid[MAX_OID_LEN]; static struct counter64 c64; if (header_generic(vp,name,length,exact,var_len,write_method) == MATCH_FAILED ) return NULL; /* * this is where we do the value assignments for the mib results. */ switch(vp->magic) { case SIPUACFGTIMERTRYING: *write_method = write_sipUACfgTimerTrying; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGTIMEREXPIRES: *write_method = write_sipUACfgTimerExpires; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGTIMERCONNECT: *write_method = write_sipUACfgTimerConnect; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGTIMERDISCONNECT: *write_method = write_sipUACfgTimerDisconnect; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGRETRYINVITE: *write_method = write_sipUACfgRetryInvite; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGRETRYBYE: *write_method = write_sipUACfgRetryBye; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGRETRYCANCEL: *write_method = write_sipUACfgRetryCancel; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGRETRYREGISTER: *write_method = write_sipUACfgRetryRegister; long_ret = 0; return (unsigned char *) &long_ret; case SIPUACFGRETRYRESPONSE: *write_method = write_sipUACfgRetryResponse; long_ret = 0; return (unsigned char *) &long_ret; case SIPSTATSRETRYINVITES: long_ret = 0; return (unsigned char *) &long_ret; case SIPSTATSRETRYBYES: long_ret = 0; return (unsigned char *) &long_ret; case SIPSTATSRETRYCANCELS: long_ret = 0; return (unsigned char *) &long_ret; case SIPSTATSRETRYREGISTERS: long_ret = 0; return (unsigned char *) &long_ret; case SIPSTATSRETRYRESPONSES: long_ret = 0; return (unsigned char *) &long_ret; default: ERROR_MSG(""); } return NULL;}intwrite_sipUACfgTimerTrying(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to sipUACfgTimerTrying not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to sipUACfgTimerTrying: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_sipUACfgTimerExpires(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to sipUACfgTimerExpires not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to sipUACfgTimerExpires: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_sipUACfgTimerConnect(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to sipUACfgTimerConnect not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to sipUACfgTimerConnect: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -