FreeBSD/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c
/*
 * Called when the module is loaded. Returning a non-zero value means,
 * rejecting the initialisation.
 *
 * We make the netgraph socket.
 */
Called when the module is loaded. Returning a non-zero value means,
rejecting the initialisation.

We make the netgraph socket.
Called when the module is loaded . Returning a non - zero value means rejecting the initialisation . We make the netgraph socket .
static int
ng_init(struct lmodule *mod, int argc, char *argv[])
{
	int name[2];
	size_t len;
	module = mod;
	if (argc == 0) {
		if ((snmp_nodename = malloc(strlen(NODENAME) + 1)) == NULL)
			return (ENOMEM);
		strcpy(snmp_nodename, NODENAME);
	} else {
		if ((snmp_nodename = malloc(NG_NODESIZ)) == NULL)
			return (ENOMEM);
		strlcpy(snmp_nodename, argv[0], NG_NODESIZ);
	}
	name[0] = CTL_KERN;
	name[1] = KERN_CLOCKRATE;
	len = sizeof(clockinfo);
	if (sysctl(name, 2, &clockinfo, &len, NULL, 0) == -1)
		return (errno);
	TAILQ_INIT(&ngtype_list);
	return (0);
}
static int ng_init ( struct lmodule * mod , int argc , char * argv [ ] ) { int name [ 2 ] ; size_t len ; module = mod ; if ( argc == 0 ) { if ( ( snmp_nodename = malloc ( strlen ( NODENAME ) + 1 ) ) == NULL ) return ( ENOMEM ) ; strcpy ( snmp_nodename , NODENAME ) ; } else { if ( ( snmp_nodename = malloc ( NG_NODESIZ ) ) == NULL ) return ( ENOMEM ) ; strlcpy ( snmp_nodename , argv [ 0 ] , NG_NODESIZ ) ; } name [ 0 ] = CTL_KERN ; name [ 1 ] = KERN_CLOCKRATE ; len = sizeof ( clockinfo ) ; if ( sysctl ( name , 2 , & clockinfo , & len , NULL , 0 ) == -1 ) return ( errno ) ; TAILQ_INIT ( & ngtype_list ) ; return ( 0 ) ; }
Called when the module is loaded.
Called when the module is loaded .
/* fetch clockinfo (for the number of microseconds per tick) */