/* 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 /* minimal include directives */ #include "mibincl.h" #include "util_funcs.h" #include "diffServMib.h" #include "diffServVariable.h" //#define number 3 //static algdrop_type[] = { 3,1,2 }; //static algdrop_next[number][number] = { 9,1,1, 9,1,2, 9,1,3 }; //static algdrop_qmeasure[number][number] = { 9,1,2, 9,1,3, 9,1,1 }; //static algdrop_qthreshold[] = { 2,3,2 }; //static algdrop_octets[] = { 38, 120, 94 }; //static algdrop_pkts[] = { 433, 1020, 4302 }; /* * var_diffServAlgDropTable(): * Handle this table separately from the scalar value case. * The workings of this are basically the same as for var_diffServMib above. */ unsigned char * var_diffServAlgDropTable(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; int index, i; /* * 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. */ if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE) == MATCH_FAILED ) return NULL; // by Ellie :) index = (int)name[*length-1] - 1; /* * this is where we do the value assignments for the mib results. */ switch(vp->magic) { case DIFFSERVALGDROPTYPE: *write_method = write_diffServAlgDropType; long_ret = 0; // by Ellie :) // long_ret = algdrop_type[index]; return (unsigned char *) &long_ret; case DIFFSERVALGDROPNEXT: *write_method = write_diffServAlgDropNext; objid[0] = 0; objid[1] = 0; *var_len = 2*sizeof(oid); // by Ellie :) // for (i=0; i sizeof(long_ret)){ fprintf(stderr,"write to diffServAlgDropType: 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; } int write_diffServAlgDropNext(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 oid *objid; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_OBJECT_ID){ fprintf(stderr, "write to diffServAlgDropNext not ASN_OBJECT_ID\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(objid)){ fprintf(stderr,"write to diffServAlgDropNext: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; objid = (oid *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in objid 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; } int write_diffServAlgDropQMeasure(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 oid *objid; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_OBJECT_ID){ fprintf(stderr, "write to diffServAlgDropQMeasure not ASN_OBJECT_ID\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(objid)){ fprintf(stderr,"write to diffServAlgDropQMeasure: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; objid = (oid *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in objid 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; } int write_diffServAlgDropQThreshold(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_GAUGE){ fprintf(stderr, "write to diffServAlgDropQThreshold not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServAlgDropQThreshold: 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; } int write_diffServAlgDropSpecific(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 oid *objid; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_OBJECT_ID){ fprintf(stderr, "write to diffServAlgDropSpecific not ASN_OBJECT_ID\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(objid)){ fprintf(stderr,"write to diffServAlgDropSpecific: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; objid = (oid *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in objid 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; } int write_diffServAlgDropStatus(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 diffServAlgDropStatus not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServAlgDropStatus: 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; }