I'm working on a Mac OSX program that controls a video processing  
card. After opening a session reading from the card works flawlessly,  
and the very first set command I send always works, but subsequent  
set commands will work or fail depending on which ones I send.
One command that sets aspect ratio (an integer 1 through 7) works  
perfectly, yet another that turns on or off a text overlay will only  
work once.

I've enabled the snmp debug messages with a ~/.snmp.conf entry and  
can see that the working packets are 50 bytes long while that ones  
that fail are only 30 bytes.

I've tried using net-snmp 5.4 and get the same behavior as Tiger's  
default  5.2.1

I'm currently opening a session and just chattering away, do I maybe  
need to close and reopen with each set request?

Objective-C code:

-(id) initWithHost:(NSString*) host
                                 community:(NSString*) community
{
        if (nil == host || nil == community) return nil;
        self = [super init];
        if (nil == self) return nil;
        
        init_snmp("SNMP-Test-Cocoa");
        struct snmp_session s;
        snmp_sess_init(&s);
        s.version = SNMP_VERSION_2c;
        s.community = (u_char*)strdup([community UTF8String]);
        s.community_len = strlen((char*)s.community);
        s.peername = strdup([host UTF8String]);
        session = snmp_open(&s);
        if (NULL == session) {
                [self release];
                return nil;
        }
        return self;
}


-(void) setOidIntValue:(NSString *)objectIdString value:(int)intVal
{
        if (NULL == session) exit;
        size_t length = MAX_OID_LEN;
        oid objectid[MAX_OID_LEN];
        read_objid([objectIdString UTF8String], objectid, &length);
        
        struct snmp_pdu *pdu = snmp_pdu_create(SNMP_MSG_SET);
        char value = intVal + 0x30;
        snmp_add_var(pdu, objectid, length, 'i', &intVal);
        struct snmp_pdu *response = NULL;

        int status = snmp_synch_response(session, pdu, &response);
     if (status == STAT_SUCCESS)
                if (response->errstat != SNMP_ERR_NOERROR)
                        NSLog(@"Error in SNMP Packet");
        if (response)
        {
                snmp_free_pdu(response);
        }
}


Ward Witt
The Filmworkers Club


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to