SK_NEW_SESSION(3)
π SK_NEW_SESSION(3) π
okay so bestie, welcome to the sk_new_session(3) page from the Library Functions Manual, and no cap this one is the blueprint for spinning up your very own SNMPSESSION. let's get into it π«Ά
β¨ NAME β¨
sk_new_session β bestie we're literally creating a brand new SNMPSESSION out here π
πΈ 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 π¦
so an SNMP_session instance? it's an object that handles alllll the details of talking to an SNMP enabled device, like a printer or a router. it's giving personal assistant energy for your network gear, fr fr.
there are three versions of sk_new_sessions (yes the family is a little chaotic). two of the parameters are identical across all of them. the first one is the one that changes between versions. iykyk.
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. so like, one of them has main character energy and the other one is on read-only mode π.
you must also provide a pointer to the start_routine function. the start_routine() is the function used to actually do the work of communicating with the network device. in other words, this function is called when the thread handling this particular device is activated. in other words (yes, again), this function actually loads up the packets with the SNMP objects and then makes the requests. 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 parameter. periodt. π«
the first parameter varies between the functions:
- in the case of
sk_new_sessionit is simply a hostname in a format understood bygethostbyname(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 - an IP address and a subnet mask in the form of either
192.168.0.0/255.255.255.0or192.168.0.0/24
- an IP address range in the form of
a hostspec may also include a community name by enclosing that in parenthesis like 192.168.0.1(public). iconic, honestly π
π 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. not the vibe, but okay, we move π
π ERRORS π
SK_MEM_FAILβ memory allocation failed. tragic.SK_BAD_PROTOβ UDP protocol is not supported. seegetprotobyname(3).SK_SOCKET_FAILβ can't create socket. seesocket(2).SK_RECEIVER_FAILβ can't create a thread to receive packets. setserrno. seepthread_create(3).SK_HOSTNOTFOUNDβ host not found. setsh_errno. seegethostbyname(3).SK_REAPER_FAILβ can't create a thread to reap spent threads. setserrno. seepthread_create(3).SK_WORKER_FAILβ can't create worker thread. setserrno. seepthread_create(3).SK_UNTERM_HOSPECβ community in hostspec doesn't have ending parenthesis. the parentheses are NOT optional bestie, close them πSK_OCTET_OVERFLOWβ one of the octets in hostspec is greater than255. ma'am that is not a real octet.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)
and that's the whole page bestie, every single option, error and reference accounted for β no gatekeeping here π«Ά
okay so that's a wrap on sk_new_session(3) from GNU snmpkit 0.4, dated November 2000. slay, bye πβ¨
π¦ where this page comes from
- ubuntu jammy: libsnmpkit-dev 0.9-16ubuntu2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms