Bluehost.com Web Hosting $6.95

RE: Table problem with ASN_IPADDRESS index

This is a discussion on RE: Table problem with ASN_IPADDRESS index within the SNMP Users forums, part of the Networking and Network Related category; Is the host or the agent running on a little endian machine? You may have to byte swap at the ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-19-2007
Adam Bell
 
Posts: n/a
Default RE: Table problem with ASN_IPADDRESS index

Is the host or the agent running on a little endian machine?
You may have to byte swap at the appropriate location to get network order.

Adam

-----Original Message-----
From: net-snmp-users-bounces@lists.sourceforge.net
[mailto:net-snmp-users-bounces@lists.sourceforge.net] On Behalf Of
maciej_golas
Sent: Monday, March 19, 2007 5:12 AM
To: net-snmp-users@lists.sourceforge.net
Subject: Table problem with ASN_IPADDRESS index

I'm new to snmp, so maybe my problem is trivial, but I couldn't find answer
to my problem.
For my MIB I created a C code using mib2c, I added a few lines to add a row
to my table to see if everything is OK.
And there is my problem, when i do snmpwalk:

$snmpwalk localhost .1.3.6.1.4.1.7777

I get:

SNMPv2-SMI::enterprises.7777.1.2.1.1.1.25.10.168.192 = IpAddress:
192.168.10.25
SNMPv2-SMI::enterprises.7777.1.2.1.1.2.25.10.168.192 = INTEGER: 12345
SNMPv2-SMI::enterprises.7777.1.2.1.1.3.25.10.168.192 = STRING: "test"

As you can see IpAddress and OID are in different order.
Maybe there is something wrong with my code from witch the row is added.

Please look at my code and table definition:

mgTestTable OBJECT-TYPE
SYNTAX SEQUENCE OF MgTableEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"This example table is implemented in the
agent/mibgroup/examples/data_set.c file."
::= { mgTestTables 1 }

mgTableEntry OBJECT-TYPE
SYNTAX MgTableEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A row describing a given working group"
INDEX { rowIp }
::= {mgTestTable 1 }

MgTableEntry ::= SEQUENCE {
rowIp IpAddress,
rowInteger INTEGER,
rowString OCTET STRING,
rowRowStatus RowStatus
}


rowIp OBJECT-TYPE
SYNTAX IpAddress
MAX-ACCESS read-create
STATUS current
DESCRIPTION
""
::= { mgTableEntry 1 }

rowInteger OBJECT-TYPE
SYNTAX INTEGER
MAX-ACCESS read-create
STATUS current
DESCRIPTION
""
::= { mgTableEntry 2 }

rowString OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-create
STATUS current
DESCRIPTION
""
::= { mgTableEntry 3 }

rowRowStatus OBJECT-TYPE
SYNTAX RowStatus
MAX-ACCESS read-create
STATUS current
DESCRIPTION "The status of this conceptual row."
::= { mgTableEntry 4 }



And my code:

/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.create-dataset.conf,v 5.4 2004/02/02 19:06:53 rstory 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 "mgTestTable.h"


void init_mgTestTable(void)
{
static oid mgTestTable_oid[] = {1,3,6,1,4,1,7777,1,2,1};
size_t mgTestTable_oid_len = OID_LENGTH(mgTestTable_oid);
netsnmp_table_data_set *table_set;

table_set = netsnmp_create_table_data_set("mgTestTable");

table_set->allow_creation = 1;

netsnmp_table_set_add_indexes(table_set, ASN_IPADDRESS, 0);

netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_ROWIP,
ASN_IPADDRESS, 1, NULL, 0,
COLUMN_ROWINTEGER,
ASN_INTEGER, 1, NULL, 0,
COLUMN_ROWSTRING,
ASN_OCTET_STR, 1, NULL, 0,
COLUMN_ROWROWSTATUS,
ASN_INTEGER, 1, NULL, 0,
0);


netsnmp_register_table_data_set(netsnmp_create_han dler_registration("mgTestT
able",
NULL,
mgTestTable_oid,
mgTestTable_oid_len,
HANDLER_CAN_RWRITE),
table_set, NULL);


char ip_val[4] = { 192, 168, 10, 25 };
int int_val = 12345;

netsnmp_table_row *row = netsnmp_create_table_data_row();

netsnmp_table_row_add_index(row, ASN_IPADDRESS, (char *) ip_val, 4);
netsnmp_set_row_column(row, COLUMN_ROWIP, ASN_IPADDRESS, (char *) ip_val,
4);
netsnmp_set_row_column(row, COLUMN_ROWINTEGER, ASN_INTEGER, (char *)
&int_val, sizeof(int));
netsnmp_set_row_column(row, COLUMN_ROWSTRING, ASN_OCTET_STR, "test",
strlen("test"));

netsnmp_table_dataset_add_row(table_set, row);

}


Could you help me with my problem.
By the way: could you please tell me how to add a row to my table using
snmpset command?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's
Techsay panel and you'll get the chance to share your opinions on IT &
business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?p...rge&CID=DEVDEV
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users

The information contained in this electronic mail transmission may be privileged and confidential, and therefore, protected from disclosure. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer without copying or disclosing it.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?p...rge&CID=DEVDEV
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0