library/src/network/nmap/BP-NMAP.cc
// attempt to stop the nmap service if it's started
attempt to stop the nmap service if it's started
attempt to stop the nmap service if it ' s started
BP_ERROR_T BP_NmapStop(P_BP_NMAP nmap)
{
	if(!nmap)
		return ERR_FAILURE;
	if(!nmap->evm)
		return ERR_FAILURE;
	if(!nmap->nmap_app)
		return ERR_FAILURE;
	if(nmap->run_status != BP_NMAP_EVENT_STATUS_RUNNING)
		return ERR_FAILURE;
	nmap->run_status = BP_NMAP_EVENT_STATUS_STOPPING;
	P_BP_EVENT_PROCESSOR nmap_processor = BP_EventMgrLookupProcessorByName(nmap->evm, NMAP_EVENT_PROCESSOR_NAME);
	printf("\n [+] nmap_processor lookup %p", nmap_processor);
	if(!nmap_processor)
		return ERR_FAILURE;
	P_BP_NMAP_EVENT_DATA nmap_event = (P_BP_NMAP_EVENT_DATA) ht_calloc(nmap->system_hreg, sizeof(BP_NMAP_EVENT_DATA), 1);
	if(!nmap_event)
	{
		return ERR_FAILURE;
	}
	nmap_event->event_type = BP_NMAP_EVENT_STOP_NMAP;
	nmap_event->nmap = nmap;
	char *tmp_uuid = BP_GenRandomUUID();
	BP_ERROR_T event_create_ret = BP_EventMgrCreateEvent
	(
			nmap->evm,
			(P_BP_EVENT_PROCESSOR) nmap_processor,
			(P_BP_EVENT_PROCESSOR) NULL,
			BP_EVENT_MESSAGES_IN,
			BP_EVENT_TYPE_MARKER_SYSTEM_CORE_EVENT,
				tmp_uuid,
			"Stopping Nmap Process",
			(void *) nmap_event,
			sizeof(nmap_event),
			BP_EVENT_PRIORITY_HIGH
	);
	if(!event_create_ret)
	{
		printf("\n [!!] Nmap stop event dispatch failed.");
	}
	printf("\n [+] Nmap stop dispatch succeeded!");
	nmap->stop_event_uuid = ht_strdup(nmap->system_hreg, (char *) tmp_uuid);
	bpfree(tmp_uuid);
	tmp_uuid = NULL;
	return event_create_ret;
}
BP_ERROR_T BP_NmapStop ( P_BP_NMAP nmap ) { if ( ! nmap ) return ERR_FAILURE ; if ( ! nmap -> evm ) return ERR_FAILURE ; if ( ! nmap -> nmap_app ) return ERR_FAILURE ; if ( nmap -> run_status != BP_NMAP_EVENT_STATUS_RUNNING ) return ERR_FAILURE ; nmap -> run_status = BP_NMAP_EVENT_STATUS_STOPPING ; P_BP_EVENT_PROCESSOR nmap_processor = BP_EventMgrLookupProcessorByName ( nmap -> evm , NMAP_EVENT_PROCESSOR_NAME ) ; printf ( " \n " , nmap_processor ) ; if ( ! nmap_processor ) return ERR_FAILURE ; P_BP_NMAP_EVENT_DATA nmap_event = ( P_BP_NMAP_EVENT_DATA ) ht_calloc ( nmap -> system_hreg , sizeof ( BP_NMAP_EVENT_DATA ) , 1 ) ; if ( ! nmap_event ) { return ERR_FAILURE ; } nmap_event -> event_type = BP_NMAP_EVENT_STOP_NMAP ; nmap_event -> nmap = nmap ; char * tmp_uuid = BP_GenRandomUUID ( ) ; BP_ERROR_T event_create_ret = BP_EventMgrCreateEvent ( nmap -> evm , ( P_BP_EVENT_PROCESSOR ) nmap_processor , ( P_BP_EVENT_PROCESSOR ) NULL , BP_EVENT_MESSAGES_IN , BP_EVENT_TYPE_MARKER_SYSTEM_CORE_EVENT , tmp_uuid , " " , ( void * ) nmap_event , sizeof ( nmap_event ) , BP_EVENT_PRIORITY_HIGH ) ; if ( ! event_create_ret ) { printf ( " \n " ) ; } printf ( " \n " ) ; nmap -> stop_event_uuid = ht_strdup ( nmap -> system_hreg , ( char * ) tmp_uuid ) ; bpfree ( tmp_uuid ) ; tmp_uuid = NULL ; return event_create_ret ; }
attempt to stop the nmap service if it's started
attempt to stop the nmap service if it ' s started
// run basic null checks // return indicating failure if the process is not running // set run status as stopping //attempt to lookup the nmap processor // display processor lookup // ensure we have a processor // create new nmap event // return indicating failure if we can't alloc // set event as a stop event // set nmap reference // create temporary uuid for the event // add start nmap /*"GR4_Start_Tor_API_Server"*/ // dispatch event check // attempt to duplicate event uuid // destroy temporary uuid before returning // return the creation return value