/* 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 q_count 1 static q_id[] = { 1 }; static q_next[q_count][3] = { 10,1,1 }; static q_minrateabs[] = { 100 }; static q_minraterel[] = { 100 }; static q_maxrateabs[] = { 500 }; static q_maxraterel[] = { 500 }; /* * var_diffServQTable(): * 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_diffServQTable(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, q_count) == 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 DIFFSERVQID: long_ret = q_id[index]; return (unsigned char *) &long_ret; case DIFFSERVQNEXT: *write_method = write_diffServQNext; /* objid[0] = 0; objid[1] = 0; *var_len = 2*sizeof(oid); */ // by Ellie :) for (i=0; i<3; i++) { objid[i] = q_next[index][i]; *var_len = 3*sizeof(oid); } return (unsigned char *) objid; case DIFFSERVQPRIORITY: *write_method = write_diffServQPriority; long_ret = 0; return (unsigned char *) &long_ret; case DIFFSERVQMINRATEABS: *write_method = write_diffServQMinRateAbs; //long_ret = 0; // by Ellie :) long_ret = q_minrateabs[index]; return (unsigned char *) &long_ret; case DIFFSERVQMINRATEREL: *write_method = write_diffServQMinRateRel; long_ret = q_minraterel[index]; return (unsigned char *) &long_ret; case DIFFSERVQMAXRATEABS: *write_method = write_diffServQMaxRateAbs; long_ret = q_maxrateabs[index]; return (unsigned char *) &long_ret; case DIFFSERVQMAXRATEREL: *write_method = write_diffServQMaxRateRel; long_ret = q_maxraterel[index]; return (unsigned char *) &long_ret; case DIFFSERVQSTATUS: *write_method = write_diffServQStatus; long_ret = 1; return (unsigned char *) &long_ret; default: ERROR_MSG(""); } return NULL; } int write_diffServQNext(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 diffServQNext not ASN_OBJECT_ID\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(objid)){ fprintf(stderr,"write to diffServQNext: 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_diffServQPriority(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 diffServQPriority not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQPriority: 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_diffServQMinRateAbs(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 diffServQMinRateAbs not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQMinRateAbs: 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_diffServQMinRateRel(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 diffServQMinRateRel not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQMinRateRel: 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_diffServQMaxRateAbs(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 diffServQMaxRateAbs not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQMaxRateAbs: 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_diffServQMaxRateRel(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 diffServQMaxRateRel not ASN_GAUGE\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQMaxRateRel: 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_diffServQStatus(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 diffServQStatus not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to diffServQStatus: 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; }