FreeBSD/sys/dev/wtap/if_wtap_module.c
/* The function called at load/unload. */
The function called at load/unload.
The function called at load / unload .
static int
event_handler(module_t module, int event, void *arg) 
{
	struct visibility_plugin *plugin;
	int e = 0; 
	switch (event) {
	case MOD_LOAD:
		sdev = make_dev(&wtap_cdevsw,0,UID_ROOT,
		    GID_WHEEL,0600,(const char *)"wtapctl");
		hal = (struct wtap_hal *)malloc(sizeof(struct wtap_hal),
		    M_WTAP, M_NOWAIT | M_ZERO);
		bzero(hal, sizeof(struct wtap_hal));
		init_hal(hal);
		plugin = (struct visibility_plugin *)malloc
		    (sizeof(struct visibility_plugin), M_WTAP_PLUGIN,
		    M_NOWAIT | M_ZERO);
		plugin->base.wp_hal  = hal;
		plugin->base.init = visibility_init;
		plugin->base.deinit = visibility_deinit;
		plugin->base.work = visibility_work;
		register_plugin(hal, (struct wtap_plugin *)plugin);
                printf("Loaded wtap wireless simulator\n");
                break;
	case MOD_UNLOAD:
		destroy_dev(sdev);
		deregister_plugin(hal);
		deinit_hal(hal);
		free(hal, M_WTAP);
		printf("Unloading wtap wireless simulator\n");
		break;
	default:
		e = EOPNOTSUPP; 
		break;
	}
	return(e);
}
static int event_handler ( module_t module , int event , void * arg ) { struct visibility_plugin * plugin ; int e = 0 ; switch ( event ) { case MOD_LOAD : sdev = make_dev ( & wtap_cdevsw , 0 , UID_ROOT , GID_WHEEL , 0600 , ( const char * ) " " ) ; hal = ( struct wtap_hal * ) malloc ( sizeof ( struct wtap_hal ) , M_WTAP , M_NOWAIT | M_ZERO ) ; bzero ( hal , sizeof ( struct wtap_hal ) ) ; init_hal ( hal ) ; plugin = ( struct visibility_plugin * ) malloc ( sizeof ( struct visibility_plugin ) , M_WTAP_PLUGIN , M_NOWAIT | M_ZERO ) ; plugin -> base . wp_hal = hal ; plugin -> base . init = visibility_init ; plugin -> base . deinit = visibility_deinit ; plugin -> base . work = visibility_work ; register_plugin ( hal , ( struct wtap_plugin * ) plugin ) ; printf ( " \n " ) ; break ; case MOD_UNLOAD : destroy_dev ( sdev ) ; deregister_plugin ( hal ) ; deinit_hal ( hal ) ; free ( hal , M_WTAP ) ; printf ( " \n " ) ; break ; default : e = EOPNOTSUPP ; break ; } return ( e ) ; }
The function called at load/unload.
The function called at load / unload .
/* Error, 0 for normal return status */ /* Setting up a simple plugin */ /* Error, Operation Not Supported */