/* * Note: this file originally auto-generated by mib2c using * : mib2c.scalar.conf,v 1.1 2002/06/19 18:50:13 hardaker Exp $ */ #include #include #include #include "enseirb.h" #include #include #include #define lp_base 0x378 #define OFF 0 #define ON 1 static int led0 = OFF; static int led1 = OFF; static int led2 = OFF; static int led3 = OFF; static int led4 = OFF; static int led5 = OFF; static int led6 = OFF; static int led7 = OFF; static char lpdata; /** Initialzies the enseirb module */ void init_enseirb(void) { static oid led0_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 1, 0 }; static oid led1_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 2, 0 }; static oid led2_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 3, 0 }; static oid led3_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 4, 0 }; static oid led4_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 5, 0 }; static oid led5_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 6, 0 }; static oid led6_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 7, 0 }; static oid led7_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 8, 0 }; DEBUGMSGTL(("enseirb", "Initializing\n")); netsnmp_register_instance( netsnmp_create_handler_registration ("led0", do_led0, led0_oid, OID_LENGTH(led0_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led1", do_led1, led1_oid, OID_LENGTH(led1_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led2", do_led2, led2_oid, OID_LENGTH(led2_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led3", do_led3, led3_oid, OID_LENGTH(led3_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led4", do_led4, led4_oid, OID_LENGTH(led4_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led5", do_led5, led5_oid, OID_LENGTH(led5_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led6", do_led6, led6_oid, OID_LENGTH(led6_oid), HANDLER_CAN_RWRITE)); netsnmp_register_instance(netsnmp_create_handler_registration ("led7", do_led7, led7_oid, OID_LENGTH(led7_oid), HANDLER_CAN_RWRITE)); // Acces port parallele ioperm(lp_base, 1, 1); // On eteint les 8 leds lpdata = 0; outb(lpdata, lp_base); } int do_led0(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led0, sizeof(led0)); DEBUGMSGTL(("enseirb", "led0 current value : %d\n", led0)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); tmp = *(requests->requestvb->val.integer); if((tmp == 0) && (led0 == 1)) send_easy_trap(SNMP_TRAP_ENTERPRISESPECIFIC, 100); // send_easy_trap(10, 10); led0 = tmp; DEBUGMSGTL(("enseirb", "led0 set now to %d\n", led0)); tmp = led0 << 0; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 0; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led1(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led1, sizeof(led1)); DEBUGMSGTL(("enseirb", "led0 current value : %d\n", led1)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led1 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led1 set now to %d\n", led1)); tmp = led1 << 1; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 1; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led2(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led2, sizeof(led2)); DEBUGMSGTL(("enseirb", "led2 current value : %d\n", led2)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led2 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led2 set now to %d\n", led2)); tmp = led2 << 2; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 2; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led3(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led3, sizeof(led3)); DEBUGMSGTL(("enseirb", "led3 current value : %d\n", led3)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led3 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led3 set now to %d\n", led3)); tmp = led3 << 3; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 3; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led4(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led4, sizeof(led4)); DEBUGMSGTL(("enseirb", "led4 current value : %d\n", led4)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led4 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led4 set now to %d\n", led4)); tmp = led4 << 4; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 4; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led5(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led5, sizeof(led5)); DEBUGMSGTL(("enseirb", "led5 current value : %d\n", led5)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led5 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led5 set now to %d\n", led5)); tmp = led5 << 5; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 5; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led6(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led6, sizeof(led6)); DEBUGMSGTL(("enseirb", "led6 current value : %d\n", led6)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led6 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led6 set now to %d\n", led6)); tmp = led6 << 6; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 6; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; } int do_led7(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { char tmp; /* * We are never called for a GETNEXT if it's registered as a * "instance", as it's "magically" handled for us. */ /* * a instance handler also only hands us one request at a time, so * we don't need to loop over a list of requests; we'll only get one. */ switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &led7, sizeof(led7)); DEBUGMSGTL(("enseirb", "led7 current value : %d\n", led7)); break; /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: /* * XXX: free resources allocated in RESERVE1 and/or * RESERVE2. Something failed somewhere, and the states * below won't be called. */ break; case MODE_SET_ACTION: /* * XXX: perform the value change here */ lpdata = inb(lp_base); led7 = *(requests->requestvb->val.integer); DEBUGMSGTL(("enseirb", "led7 set now to %d\n", led7)); tmp = led7 << 7; if(tmp) lpdata = lpdata | tmp; else { tmp = 1 << 7; lpdata = lpdata & (~tmp); } outb(lpdata, lp_base); break; case MODE_SET_COMMIT: /* * XXX: delete temporary storage */ break; case MODE_SET_UNDO: /* * XXX: UNDO and return to previous value for the object */ break; default: /* * we should never get here, so this is a really bad error */ return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; }