• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SNMP API and Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SNMP API and Cocoa


  • Subject: SNMP API and Cocoa
  • From: Ward Witt <email@hidden>
  • Date: Wed, 30 May 2007 10:47:41 -0500

Does anyone on this list have experience using net-snmp set commands?

I've got a situation where I'm opening a session to a video processing card I want to control. 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

-(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 _______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSTableColumn 'enabled' binding not in 10.3? Any others?
  • Next by Date: Re: NSTableColumn 'enabled' binding not in 10.3? Any others?
  • Previous by thread: How can I reset QTMovieView contents?
  • Next by thread: rotated text in NSTextView
  • Index(es):
    • Date
    • Thread