📄 sipreg.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 "sipReg.h"/* * sipReg_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 sipReg_variables_oid[] = { 1,3,6,1,4,1,5738,3,42,1,6 };/* * variable4 sipReg_variables: * this variable defines function callbacks and type return information * for the sipReg mib section */struct variable4 sipReg_variables[] = {/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */#define SIPREGALLOWTHIRDPARTY 1 { SIPREGALLOWTHIRDPARTY, ASN_INTEGER , RWRITE, var_sipReg, 2, { 1,1 } },#define SIPREGCONTACTDFLTEXPIRYDURATION 2 { SIPREGCONTACTDFLTEXPIRYDURATION, ASN_GAUGE , RWRITE, var_sipReg, 2, { 1,2 } },#define SIPREGCONTACTDFLTEXPIRYDATE 3 { SIPREGCONTACTDFLTEXPIRYDATE, ASN_OCTET_STR , RWRITE, var_sipReg, 2, { 1,3 } },#define SIPREGMAXCONTACTEXPIRYDATE 4 { SIPREGMAXCONTACTEXPIRYDATE, ASN_GAUGE , RWRITE, var_sipReg, 2, { 1,4 } },#define SIPREGRESPHASCONTACTS 5 { SIPREGRESPHASCONTACTS, ASN_INTEGER , RWRITE, var_sipReg, 2, { 1,5 } },#define SIPREGMAXUSERS 6 { SIPREGMAXUSERS , ASN_GAUGE , RONLY , var_sipReg, 2, { 1,6 } },#define SIPREGCURRENTUSERS 7 { SIPREGCURRENTUSERS , ASN_GAUGE , RONLY , var_sipReg, 2, { 1,7 } },#define SIPUSERURI 11 { SIPUSERURI , ASN_OCTET_STR , RWRITE, var_sipRegUserTable, 4, { 1,8,1,2 } },#define SIPUSERPASSWORD 12 { SIPUSERPASSWORD , ASN_OCTET_STR , RWRITE, var_sipRegUserTable, 4, { 1,8,1,3 } },#define SIPUSERAUTHENTICATIONFAILURES 13 { SIPUSERAUTHENTICATIONFAILURES, ASN_COUNTER , RONLY , var_sipRegUserTable, 4, { 1,8,1,4 } },#define SIPUSERTABLEROWSTATUS 14 { SIPUSERTABLEROWSTATUS, ASN_INTEGER , RWRITE, var_sipRegUserTable, 4, { 1,8,1,5 } },#define SIPCONTACTDISPLAYNAME 18 { SIPCONTACTDISPLAYNAME, ASN_OCTET_STR , RONLY , var_sipContactTable, 4, { 1,9,1,2 } },#define SIPCONTACTURI 19 { SIPCONTACTURI , ASN_OCTET_STR , RONLY , var_sipContactTable, 4, { 1,9,1,3 } },#define SIPCONTACTLASTUPDATED 20 { SIPCONTACTLASTUPDATED, ASN_TIMETICKS , RONLY , var_sipContactTable, 4, { 1,9,1,4 } },#define SIPCONTACTEXPIRY 21 { SIPCONTACTEXPIRY , ASN_OCTET_STR , RONLY , var_sipContactTable, 4, { 1,9,1,5 } },#define SIPCONTACTPREFERENCE 22 { SIPCONTACTPREFERENCE, ASN_OCTET_STR , RONLY , var_sipContactTable, 4, { 1,9,1,6 } },#define SIPCONTACTACTION 23 { SIPCONTACTACTION , ASN_INTEGER , RONLY , var_sipContactTable, 4, { 1,9,1,7 } },#define SIPCONTACTRETRYAFTER 24 { SIPCONTACTRETRYAFTER, ASN_OCTET_STR , RONLY , var_sipContactTable, 4, { 1,9,1,8 } },#define SIPREGACCEPTEDREGISTRATIONS 25 { SIPREGACCEPTEDREGISTRATIONS, ASN_COUNTER , RONLY , var_sipReg, 2, { 2,1 } },#define SIPREGREJECTEDREGISTRATIONS 26 { SIPREGREJECTEDREGISTRATIONS, ASN_COUNTER , RONLY , var_sipReg, 2, { 2,2 } },};/* (L = length of the oidsuffix) *//* * init_sipReg(): * Initialization routine. This is called when the agent starts up. * At a minimum, registration of your variables should take place here. */void init_sipReg(void) { /* register ourselves with the agent to handle our mib tree */ REGISTER_MIB("sipReg", sipReg_variables, variable4, sipReg_variables_oid); /* place any other initialization junk you need here */}/* * var_sipReg(): * 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_sipReg(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 SIPREGALLOWTHIRDPARTY: *write_method = write_sipRegAllowThirdParty; long_ret = 0; return (unsigned char *) &long_ret; case SIPREGCONTACTDFLTEXPIRYDURATION: *write_method = write_sipRegContactDfltExpiryDuration; long_ret = 0; return (unsigned char *) &long_ret; case SIPREGCONTACTDFLTEXPIRYDATE: *write_method = write_sipRegContactDfltExpiryDate; *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPREGMAXCONTACTEXPIRYDATE: *write_method = write_sipRegMaxContactExpiryDate; long_ret = 0; return (unsigned char *) &long_ret; case SIPREGRESPHASCONTACTS: *write_method = write_sipRegRespHasContacts; long_ret = 0; return (unsigned char *) &long_ret; case SIPREGMAXUSERS: long_ret = 0; return (unsigned char *) &long_ret; case SIPREGCURRENTUSERS: long_ret = 0; return (unsigned char *) &long_ret; case SIPREGACCEPTEDREGISTRATIONS: long_ret = 0; return (unsigned char *) &long_ret; case SIPREGREJECTEDREGISTRATIONS: long_ret = 0; return (unsigned char *) &long_ret; default: ERROR_MSG(""); } return NULL;}/* * var_sipContactTable(): * Handle this table separately from the scalar value case. * The workings of this are basically the same as for var_sipReg above. */unsigned char *var_sipContactTable(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; /* * This assumes that the table is a 'simple' table. * See the implementation documentation for the meaning of this. * You will need to provide the correct value for the TABLE_SIZE parameter * * If this table does not meet the requirements for a simple table, * you will need to provide the replacement code yourself. * Mib2c is not smart enough to write this for you. * Again, see the implementation documentation for what is required. */#define TABLE_SIZE 1 // todo: replace if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE) == MATCH_FAILED ) return NULL; /* * this is where we do the value assignments for the mib results. */ switch(vp->magic) { case SIPCONTACTDISPLAYNAME: *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPCONTACTURI: *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPCONTACTLASTUPDATED: long_ret = 0; return (unsigned char *) &long_ret; case SIPCONTACTEXPIRY: *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPCONTACTPREFERENCE: *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPCONTACTACTION: long_ret = 0; return (unsigned char *) &long_ret; case SIPCONTACTRETRYAFTER: *string = 0; *var_len = strlen(string); return (unsigned char *) string; default: ERROR_MSG(""); } return NULL;}/* * var_sipRegUserTable(): * Handle this table separately from the scalar value case. * The workings of this are basically the same as for var_sipReg above. */unsigned char *var_sipRegUserTable(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; /* * This assumes that the table is a 'simple' table. * See the implementation documentation for the meaning of this. * You will need to provide the correct value for the TABLE_SIZE parameter * * If this table does not meet the requirements for a simple table, * you will need to provide the replacement code yourself. * Mib2c is not smart enough to write this for you. * Again, see the implementation documentation for what is required. */#define TABLE_SIZE 1 // todo remove if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE) == MATCH_FAILED ) return NULL; /* * this is where we do the value assignments for the mib results. */ switch(vp->magic) { case SIPUSERURI : *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPUSERPASSWORD : *string = 0; *var_len = strlen(string); return (unsigned char *) string; case SIPUSERAUTHENTICATIONFAILURES : long_ret = 0; return (unsigned char *) &long_ret; case SIPUSERTABLEROWSTATUS : long_ret = 0; return (unsigned char *) &long_ret; default: ERROR_MSG(""); } return NULL;}intwrite_sipRegAllowThirdParty(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 sipRegAllowThirdParty not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to sipRegAllowThirdParty: 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_sipRegContactDfltExpiryDuration(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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -