hi everybody
basically i want to create and design a mib for my equipment and for that i
get the parameters by calling the webservice
i am snedig u the VIDIP-MIB.txt file for ur understanding basically i want
to know how i can manage the Source table using the mib2c -c
mib2c.iterate.conf vidip actually i will also send the process.c file and
also the output the problem is only of the source entry
*********************************************
Process.c***********************************************************
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.iterate.conf,v 5.19 2006/09/07 16:17:35 dts12 Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net- snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "process.h"
#include "GlobalDefine.h"
#include "ctaskH.h"
/** Initializes the vidip module */
void
init_process(void)
{
initialize_table_SourceTable();
}
/** Initialize the SourceTable table by defining its contents and how it's
structured */
void
initialize_table_SourceTable(void)
{
static oid SourceTable_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 3, 1 };
size_t SourceTable_oid_len = OID_LENGTH(SourceTable_oid);
netsnmp_handler_registration *reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
reg =
netsnmp_create_handler_registration("SourceTable",
SourceTable_handler,
SourceTable_oid,
SourceTable_oid_len,
HANDLER_CAN_RWRITE);
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: ID
*/
0);
table_info->min_column = COLUMN_ID;
table_info->max_column = COLUMN_CONFIGID;
iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
iinfo->get_first_data_point = SourceTable_get_first_data_point;
iinfo->get_next_data_point = SourceTable_get_next_data_point;
iinfo->table_reginfo = table_info;
netsnmp_register_table_iterator(reg, iinfo);
/*
* Initialise the contents of the table here
*/
}
/*
* Typical data structure for a row entry
*/
struct SourceTable_entry {
/*
* Index values
*/
long ID;
/*
* Column values
*/
long ConfigID;
long old_ConfigID;
/*
* Illustrate using a simple linked list
*/
int valid;
struct SourceTable_entry *next;
};
struct SourceTable_entry *SourceTable_head;
/*
* create a new row in the (unsorted) table
*/
struct SourceTable_entry *
SourceTable_createEntry(long ID)
{
struct SourceTable_entry *entry;
entry = SNMP_MALLOC_TYPEDEF(struct SourceTable_entry);
if (!entry)
return NULL;
entry->ID = ID;
entry->next = SourceTable_head;
SourceTable_head = entry;
return entry;
}
/*
* remove a row from the table
*/
void
SourceTable_removeEntry(struct SourceTable_entry *entry)
{
struct SourceTable_entry *ptr, *prev;
if (!entry)
return; /* Nothing to remove */
for (ptr = SourceTable_head, prev = NULL;
ptr != NULL; prev = ptr, ptr = ptr->next) {
if (ptr == entry)
break;
}
if (!ptr)
return; /* Can't find it */
if (prev == NULL)
SourceTable_head = ptr->next;
else
prev->next = ptr->next;
SNMP_FREE(entry); /* XXX - release any other internal
resources */
}
/*
* Example iterator hook routines - using 'get_next' to do most of the work
*/
netsnmp_variable_list *
SourceTable_get_first_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list * put_index_data,
netsnmp_iterator_info *mydata)
{
*my_loop_context = SourceTable_head;
return SourceTable_get_next_data_point(my_loop_context,
my_data_context, put_index_data,
mydata);
}
netsnmp_variable_list *
SourceTable_get_next_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list * put_index_data,
netsnmp_iterator_info *mydata)
{
struct SourceTable_entry *entry =
(struct SourceTable_entry *) *my_loop_context;
netsnmp_variable_list *idx = put_index_data;
if (entry) {
snmp_set_var_typed_integer(idx, ASN_INTEGER, entry->ID);
idx = idx->next_variable;
*my_data_context = (void *) entry;
*my_loop_context = (void *) entry->next;
return put_index_data;
} else {
return NULL;
}
}
/** handles requests for the SourceTable table */
int
SourceTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
struct SourceTable_entry *table_entry;
switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
for (request = requests; request; request = request->next) {
table_entry = (struct SourceTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
//WS
struct soap soap;
soap_init(&soap);
ct__ArrayOfConfigProcess result;
soap_call_ct__GetProcessList(&soap," http://127.0.0.1:18083","",
result);
for(int i=0; i<result.__size; ++i) {
result[i];
}
switch (table_info->colnum) {
case COLUMN_ID:
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,2
/*table_entry->ID*/);
break;
case COLUMN_CONFIGID:
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,1
/*table_entry->ConfigID*/);
break;
default:
// An unsupported/unreadable column (if applicable)
snmp_set_var_typed_value(request->requestvb,
SNMP_NOSUCHOBJECT, NULL, 0);
}
}
break;
/*
* Write-support
*/
case MODE_SET_RESERVE1:
for (request = requests; request; request = request->next) {
table_entry = (struct SourceTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_CONFIGID:
/*
* or possibly 'netsnmp_check_vb_int_range'
*/
int ret = netsnmp_check_vb_int(request->requestvb);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, request, ret);
return SNMP_ERR_NOERROR;
}
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_ERR_NOTWRITABLE);
return SNMP_ERR_NOERROR;
}
}
break;
case MODE_SET_RESERVE2:
break;
case MODE_SET_FREE:
break;
case MODE_SET_ACTION:
for (request = requests; request; request = request->next) {
table_entry = (struct SourceTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_CONFIGID:
table_entry->old_ConfigID = table_entry->ConfigID;
table_entry->ConfigID = *request->requestvb->val.integer;
break;
}
}
break;
case MODE_SET_UNDO:
for (request = requests; request; request = request->next) {
table_entry = (struct SourceTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_CONFIGID:
table_entry->ConfigID = table_entry->old_ConfigID;
table_entry->old_ConfigID = 0;
break;
}
}
break;
case MODE_SET_COMMIT:
break;
}
return SNMP_ERR_NOERROR;
}
********************************
VIDIP-MIB.txt***************************************************************
VIDIP-MIB DEFINITIONS::= BEGIN
IMPORTS
enterprises, OBJECT-TYPE, Unsigned32, Integer32, TimeTicks, IpAddress,
Counter32,OBJECT-IDENTITY, NOTIFICATION-TYPE
FROM SNMPv2-SMI;
--
-- A brief description and update information about this mib.
--
vidip MODULE-IDENTITY
LAST-UPDATED "0104010000Z" -- September 2007, morrning
ORGANIZATION "vidIP"
CONTACT-INFO "
Author: MIR WAJAHAT
vidIP
Mediatvcom Headquarter
215, rue Jean-Jacques Rousseau
92136 Issy les Moulineaux cedex
France
email: [EMAIL PROTECTED]
phone: +33 1 41 46 00 99
"
DESCRIPTION "MIB for remote control by SNMP
"
::= { enterprises 9362 }
unitinfo OBJECT IDENTIFIER::= { vidip 1 }
General OBJECT IDENTIFIER::= { vidip 2 }
Source OBJECT IDENTIFIER::= { vidip 3 }
reserved OBJECT IDENTIFIER::= { vidip 4 }
--
-- Serial Number
--
SerialNumber OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Serial Number of VIDIP."
DEFVAL { 0 }
::= { unitinfo 1 }
--
--Version
--
Version OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Version Number of VIDIP."
DEFVAL { 0 }
::= { unitinfo 2 }
--
--NIC
--
NIC OBJECT-TYPE
SYNTAX Integer32 (0..20)
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Network Interface Card Number of VIDIP."
DEFVAL { 0 }
::= { unitinfo 3 }
--
--CPU
--
CPU OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Central Processing Unit Number of VIDIP."
DEFVAL { 0 }
::= { unitinfo 4 }
--
--RAM
--
RAM OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the size of the RAM of VIDIP."
DEFVAL { 0 }
::= { unitinfo 5 }
--
--Hard Disk
--
HD OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the size of the Hard Disk of VIDIP."
DEFVAL { 0 }
::= { unitinfo 6}
--
--Mother Board
--
MB OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the specification of the Mother Board of VIDIP."
DEFVAL { 0 }
::= { unitinfo 7}
--
--Configuration ID
--
ConfigID OBJECT-TYPE
SYNTAX Integer32 (0..1000)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Configuration ID of VIDIP."
DEFVAL { 1 }
::= {General 1 }
--
-- Configuration Name
--
ConfigName OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Configuration Name of VIDIP."
DEFVAL { 0 }
::= { General 2 }
--
-- Host Name
--
Hostname OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Host Name of VIDIP."
DEFVAL { 0 }
::= { General 3 }
--
-- Default Gateway
--
DefaultGateway OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the Default Gateway of VIDIP."
DEFVAL { 0 }
::= { General 4 }
--
-- Syslog
--
Syslog OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display Syslog of VIDIP.."
DEFVAL { 0 }
::= { General 5 }
--
-- LogLevel
--
LogLevel OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"DEFVAL 0 will display the LogLevel of VIDIP."
DEFVAL { 0 }
::= { General 6 }
--
-- Interfaces
--
InterfaceTable OBJECT-TYPE
SYNTAX SEQUENCE OF NetSnmpIETFWGEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Entrée du tableau."
::= {General 7 }
InterfaceEntry OBJECT-TYPE
SYNTAX InterfaceEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A row describing a given working group"
INDEX { Name }
::= {InterfaceTable 1 }
InterfaceEntry ::= SEQUENCE {
Name OCTET STRING,
PhysicalDevice OCTET STRING,
IpAddress OCTET STRING,
Netmask OCTET STRING,
RoutingMode OCTET STRING,
Gateway OCTET STRING,
Vlan OCTET STRING,
Duplex OCTET STRING,
Speed OCTET STRING,
Autoneg OCTET STRING
}
Name OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 1 }
PhysicalDevice OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 2 }
IpAddress OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 3 }
Netmask OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 4 }
RoutingMode OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 5 }
Gateway OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 6 }
Vlan OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 7 }
Duplex OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 8 }
Speed OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 9 }
Autoneg OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1000))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= { InterfaceEntry 10}
--
-- Source
--
SourceTable OBJECT-TYPE
SYNTAX SEQUENCE OF SourceEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Entrée du tableau."
::= {Source 1}
SourceEntry OBJECT-TYPE
SYNTAX SourceEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A row describing a given working group"
INDEX { ID }
::= {SourceTable 1}
SourceEntry ::= SEQUENCE {
ID Integer32,
ConfigID Integer32,
Drains DrainEntry
}
ID OBJECT-TYPE
SYNTAX Integer32 (0..1000)
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= {SourceEntry 1 }
ConfigID OBJECT-TYPE
SYNTAX Integer32 (0..1000)
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Sous nom de l'index"
::= {SourceEntry 2 }
END
****************************************output of this file
********************************************************
VIDIP-MIB::SerialNumber.0 = STRING: "SN070293"
VIDIP-MIB::NIC.0 = INTEGER: 8
VIDIP-MIB::CPU.0 = STRING: "P3-1267MHz"
VIDIP-MIB::RAM.0 = STRING: "256"
VIDIP-MIB::HD.0 = STRING: "PQI 128"
VIDIP-MIB::MB.0 = STRING: "Adlink EBC2000"
VIDIP-MIB::ConfigID.0 = INTEGER: 0
VIDIP-MIB::ConfigName.0 = STRING: "Config2"
VIDIP-MIB::Hostname.0 = STRING: "Canard"
VIDIP-MIB::DefaultGateway.0 = ""
VIDIP-MIB::Syslog.0 = STRING: "1.1.1.2"
VIDIP-MIB::LogLevel.0 = STRING: "5"
VIDIP-MIB::PhysicalDevice."eth0" = STRING: "eth0"
VIDIP-MIB::PhysicalDevice."eth0.12" = STRING: "eth0"
VIDIP-MIB::PhysicalDevice."eth0.20" = STRING: "eth0"
VIDIP-MIB::IpAddress."eth0" = STRING: " 10.10.10.238"
VIDIP-MIB::IpAddress."eth0.12" = STRING: "10.10.10.252"
VIDIP-MIB::IpAddress."eth0.20" = STRING: " 1.1.1.1"
VIDIP-MIB::Netmask."eth0" = STRING: "255.255.255.0"
VIDIP-MIB::Netmask."eth0.12" = STRING: "255.255.255.0 "
VIDIP-MIB::Netmask."eth0.20" = STRING: "255.255.255.0"
VIDIP-MIB::RoutingMode."eth0" = STRING: "none"
VIDIP-MIB::RoutingMode." eth0.12" = STRING: "bridged"
VIDIP-MIB::RoutingMode."eth0.20" = STRING: "routed"
VIDIP-MIB::Gateway."eth0" = ""
VIDIP-MIB::Gateway."eth0.12" = ""
VIDIP-MIB::Gateway."eth0.20" = STRING: "1.1.1.254"
VIDIP-MIB::Vlan."eth0" = ""
VIDIP-MIB::Vlan."eth0.12" = STRING: "12"
VIDIP-MIB::Vlan."eth0.20" = STRING: "20"
VIDIP-MIB::Duplex."eth0" = STRING: "half"
VIDIP-MIB::Duplex."eth0.12" = ""
VIDIP-MIB::Duplex."eth0.20" = ""
VIDIP-MIB::Speed."eth0" = STRING: "10"
VIDIP-MIB::Speed."eth0.12" = ""
VIDIP-MIB::Speed."eth0.20" = ""
VIDIP-MIB::Autoneg."eth0" = STRING: "on"
VIDIP-MIB::Autoneg."eth0.12" = ""
VIDIP-MIB::Autoneg."eth0.20" = ""
VIDIP-MIB::SourceEntry.3 = INTEGER: 1
--
MIR Wajahat Ghaffar
M1 Telecom/Réseaux
EFREI
Ecole d'Ingénieurs des Technologies de l'Information et du Management
30-32, avenue de la République
94815 VILLEJUIF cedex
www.efrei.fr
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users