1 | /* |
---|
2 | * Note: this file originally auto-generated by mib2c using |
---|
3 | * : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $ |
---|
4 | */ |
---|
5 | |
---|
6 | #include <net-snmp/net-snmp-config.h> |
---|
7 | #include <net-snmp/net-snmp-includes.h> |
---|
8 | #include <net-snmp/agent/net-snmp-agent-includes.h> |
---|
9 | #include "syn3Version.h" |
---|
10 | |
---|
11 | /** Initializes the syn3Version module */ |
---|
12 | void |
---|
13 | init_syn3Version(void) |
---|
14 | { |
---|
15 | static oid syn3VersionString_oid[] = { 1,3,6,1,4,1,31337,1,1,1 }; |
---|
16 | |
---|
17 | DEBUGMSGTL(("syn3Version", "Initializing\n")); |
---|
18 | |
---|
19 | //Set defaults |
---|
20 | strncpy(syn3Version,"unknown",strlen("unknown")); |
---|
21 | |
---|
22 | netsnmp_register_scalar( |
---|
23 | netsnmp_create_handler_registration("syn3VersionString", handle_syn3VersionString, |
---|
24 | syn3VersionString_oid, OID_LENGTH(syn3VersionString_oid), |
---|
25 | HANDLER_CAN_RONLY |
---|
26 | )); |
---|
27 | } |
---|
28 | |
---|
29 | int |
---|
30 | handle_syn3VersionString(netsnmp_mib_handler *handler, |
---|
31 | netsnmp_handler_registration *reginfo, |
---|
32 | netsnmp_agent_request_info *reqinfo, |
---|
33 | netsnmp_request_info *requests) |
---|
34 | { |
---|
35 | int err=SNMP_ERR_NOERROR; |
---|
36 | FILE *file; |
---|
37 | file=fopen(syn3Version_file,"r"); |
---|
38 | |
---|
39 | if(file==NULL) |
---|
40 | { |
---|
41 | snmp_log(LOG_ERR, "Cannot read file %s \n",syn3Version_file); |
---|
42 | //We don't set an error, because the version file isn't that important. |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | fgets(syn3Version,10,file); |
---|
47 | fclose(file); |
---|
48 | } |
---|
49 | |
---|
50 | switch(reqinfo->mode) { |
---|
51 | |
---|
52 | case MODE_GET: |
---|
53 | snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR, |
---|
54 | (u_char *) syn3Version, |
---|
55 | strlen(syn3Version)); |
---|
56 | break; |
---|
57 | |
---|
58 | |
---|
59 | default: |
---|
60 | /* we should never get here, so this is a really bad error */ |
---|
61 | snmp_log(LOG_ERR, "unknown mode (%d) in handle_syn3VersionString\n", reqinfo->mode ); |
---|
62 | err=SNMP_ERR_GENERR; |
---|
63 | } |
---|
64 | |
---|
65 | return err; |
---|
66 | } |
---|