Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sk_new_session(3) [debian man page]

SK_NEW_SESSION(3)					     Library Functions Manual						 SK_NEW_SESSION(3)

NAME
sk_new_session - create a new SNMPSESSION SYNOPSIS
#include <snmpkit.h> SNMPSESSION *sk_new_session(char *host, void *(start_routine)(SNMPSESSION*), const char *community); SNMPSESSION **sk_new_sessions(char *hostspec,const char *community,void *(start_routine)(SNMPSESSION*)); SNMPSESSION **sk_new_sessions_multi(char **hostspecs, const char *community, void *(start_routine)(SNMPSESSION*)); DESCRIPTION
An SNMP_session instance is an object that handles the details of communicating an SNMP enabled device such as a printer or a router. There are three versions of sk_new_sessions. They two of the parmeters are identical. The first one varies between the different versions of the function. A SNMP community string acts as a password. Normally there are two strings set for an SNMP enabled device. One will allow the user write access to settings via SNMP commands and the second password will only allow for read access to device settings. You must also provide a pointer to the start_routine function. The start_routine() is the function used to actually do the work of commu- nicating with the network device. In other words, this function is called when the thread handling this particular device is activated. In other words, this function actually loads up the packets with the SNMP objects and then makes the requsts. Each SNMPSESSION has its own thread and once the thread is created. When the start_function function is called, it is passed the SNMPSESSION pointer as a paramter. The first parameter varies between the functions. In the case of sk_new_session it is simply a hostname in a format understood by gethost- byname(3). In the case of sk_new_sessions, instead of a simple hostname a hostspec is passed in. A hostspec can be a simple hostname but it can also be an IP address range in the form of 192.168.0.1-5 or an IP address and a subnet mask in the form of either 192.168.0.0/255.255.255.0 or 192.168.0.0/24. A hostspec may also include a community name by enclosing that in parenthesis like 192.168.0.1(public). RETURN VALUE
Upon successful completion sk_new_session returns a pointer to a SNMPSESSION. sk_new_sessions and sk_new_sessions_multi both return a null terminated array of SNMPSESSION pointers. Otherwise NULL is returned and sk_errno is set to indicate the error. ERRORS
SK_MEM_FAIL Memory allocation failed. SK_BAD_PROTO UDP protocol is not supported. See getprotobyname(3). SK_SOCKET_FAIL Can't create socket. See socket(2). SK_RECEIVER_FAIL Can't create a thread to receive packets. Sets errno. See pthread_create(3). SK_HOSTNOTFOUND Host not found. Sets h_errno. See gethostbyname(3). SK_REAPER_FAIL Can't create a thread to reap spent threads. Sets errno. See pthread_create(3). SK_WORKER_FAIL Can't create worker thread. Sets errno. See pthread_create(3). SK_UNTERM_HOSPEC Community in hostspec doesn't have ending parenthesis. SK_OCTET_OVERFLOW One of the octets in hostspec is greater than 255. SK_BAD_NETMASK Subnet mask wasn't in a understood form. SK_NETMASK_OVERFLOW Number of bits in subnet mask is too large. SK_DIS_NETMASK Subnet mask had discontinious bits. SEE ALSO
sk_strerror(3), sk_snmpsessions_done(3), sk_new_sfiller(3), sk_new_snmptable(3) GNU snmpkit 0.4 November 2000 SK_NEW_SESSION(3)

Check Out this Related Man Page

snmpsession(3)						     Library Functions Manual						    snmpsession(3)

NAME
snmpsession - snmpkit functions dealing with a particular snmpsession. SYNOPSIS
#include <snmpkit.h> SNMPSESSION *sk_new_session(char *host, void *(start_routine)(SNMPSESSION*), const char *community); DESCRIPTION
A snmpsession is an opaque data structure which specifies a The new_snmpsession() creates a new session. The SNMPSOCK should have previously created by the application using, new_snmpsock(). The host should will be looked up using gethostbyname() and the community string is something like a password in SNMP lingo but it doesn't have a username associated with it and it is transmitted in clear text within the packets. In most cases, there are a couple of community strings. One is only allowed to read and the other is allowed to both read and write. The default read-only community name is "public". If set the community name to NULL, the community name will default to public. The new_snmpsession_quick() function is very similar to the new_snmpsession() function except the community name always defaults to "pub- lic". The delete_snmpsock() function is the opposite of the new_snmpsession() function. It frees all memory and resources currently being used by the SNMPSESSION structure. RETURN VALUE
The new_snmpsock() and the new_snmpsock_quick() both return a pointer to the newly created snmpsock or NULL if there was an error. AUTHOR
Ben Woodard <ben@users.sourceforge.net> BUGS
The library can possibly throw different kinds of C++ exceptions that won't be caught by the glue code and therefore it can cause your pro- gram to crash inexplicably. SEE ALSO
libsnmpkit(3), snmpsock(3), snmpstructfiller(3), snmptable(3), gethostbyname(3) GNU snmpkit 0.4 November 2000 snmpsession(3)
Man Page