static void dn_run(struct instance *nci) { rstatus_t status; struct context *ctx; ctx = core_start(nci); if (ctx == NULL) { return; } ctx->enable_gossip = enable_gossip; ctx->admin_opt = admin_opt; if (!ctx->enable_gossip) ctx->dyn_state = NORMAL; /* run rabbit run */ for (;;) { status = core_loop(ctx); if (status != DN_OK) { break; } } core_stop(ctx); }
int main(int argc, char **argv) { int ret; pcap_wrapper *pw; char ch, filter[128], is_usage = 0, show_version = 0; while((ch = getopt(argc, argv, "s:p:i:S:Cd:l:hv")) != -1) { switch(ch) { case 's': opts.server = strdup(optarg); break; case 'p': opts.port= atoi(optarg); break; case 'i': opts.device = strdup(optarg); break; case 'S': opts.script = strdup(optarg); break; case 'C': opts.is_calc_mode = 1; break; case 'd': opts.duration = atoi(optarg); break; case 'l': opts.specified_addresses = 1; if (parse_addresses(optarg)) { logger(ERROR, "parsing local addresses\n"); return EXIT_FAILURE; } break; case 'f': opts.log_file = strdup(optarg); break; case 'h': is_usage = 1; break; case 'v': show_version= 1; break; } } if( is_usage ) { usage(argv[0]); exit(0); } if(show_version) { printf("%s version is %s\n", argv[0], VERSION); exit(0); } if(!opts.specified_addresses && get_addresses() != 0) { exit(0); } if (!opts.port) logger(ERROR, "port is required.\n"); if (!opts.device) logger(ERROR, "device is required.\n"); if (opts.log_file) set_log_file(opts.log_file); if (!(pw = pw_create(opts.device))) logger(ERROR, "start captrue packet failed.\n"); if(opts.server) { snprintf(filter, sizeof(filter), "host %s and tcp port %d", opts.server, opts.port); } else { snprintf(filter, sizeof(filter), "tcp port %d", opts.port); } check_lua_script(); // start capature loop. ret = core_loop(pw, filter, process_packet); if(ret == -1) logger(ERROR, "start core loop failed.\n"); pw_release(pw); script_release(L); return 0; }
static void mcp_run(struct context *ctx) { rstatus_t status; core_start(ctx); for (;;) { status = core_loop(ctx); if (status != MCP_OK) { break; } } }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC1_Init(); MX_CAN1_Init(); MX_I2C1_Init(); MX_SPI2_Init(); MX_TIM1_Init(); MX_TIM3_Init(); MX_USART3_UART_Init(); MX_USB_DEVICE_Init(); MX_TIM5_Init(); /* USER CODE BEGIN 2 */ core_setup(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ core_loop(); } /* USER CODE END 3 */ }
int main() { log_init(&logger,NULL,LOG_LEVEL_VERB); log_info("server test start"); struct context *ctx; struct conn* conn; ctx = core_init(); conn = server_create_conn("127.0.0.1", 80, ctx); conn->conn_parse = conn_parse1; conn->conn_close = conn_close1; core_loop(ctx); core_destory(ctx); //conn_close(conn); log_deinit(&logger); return 0; }
static void dn_run(struct instance *nci) { rstatus_t status; struct context *ctx; ctx = core_start(nci); if (ctx == NULL) { return; } /* run rabbit run */ for (;;) { status = core_loop(ctx); if (status != DN_OK) { break; } } core_stop(ctx); }
static void nc_run(struct instance *nci) { rstatus_t status; struct context *ctx; ctx = core_start(nci); if (ctx == NULL) { return; } /* whitelist thread */ nc_get_whitelist(nci); /* run rabbit run */ for (;;) { status = core_loop(ctx); if (status != NC_OK) { break; } } core_stop(ctx); }
// The main function int init(unsigned long magic, multiboot_info_t* hdr) { setGDT(); init_heap(); #ifdef SLAB slab_alloc_init(); #endif textInit(); /** * \todo Make complement_heap so that it allocates memory from pte */ complement_heap(&end, HEAPSIZE); addr_t tmp = (addr_t)hdr + offset; hdr = (multiboot_info_t*)tmp; if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf("\nInvalid magic word: %X\n", magic); panic(""); } if (hdr->flags & MULTIBOOT_INFO_MEMORY) { memsize = hdr->mem_upper; memsize += 1024; } else panic("No memory flags!"); if (!(hdr->flags & MULTIBOOT_INFO_MEM_MAP)) panic("Invalid memory map"); mmap = (multiboot_memory_map_t*) hdr->mmap_addr; /** Build the memory map and allow for allocation */ x86_pte_init(); page_alloc_init(mmap, (unsigned int)hdr->mmap_length); vm_init(); #ifdef PA_DBG // endProg(); #endif /** In the progress of phasing out */ /** Set up paging administration */ x86_page_init(memsize); mboot_page_setup(mmap, (uint32_t)hdr->mmap_length); mboot_map_modules((void*)hdr->mods_addr, hdr->mods_count); /** For now this is the temporary page table map */ build_map(mmap, (unsigned int) hdr->mmap_length); /** end of deprication */ task_init(); page_init(); printf(WELCOME); // The only screen output that should be maintained page_unmap_low_mem(); pic_init(); setIDT(); setup_irq_data(); if (dev_init() != -E_SUCCESS) panic("Couldn't initialise /dev"); ol_pit_init(1024); // program pic to 1024 hertz debug("Size of the heap: 0x%x\tStarting at: %x\n", HEAPSIZE, heap); acpi_init(); ol_cpu_t cpu = kalloc(sizeof (*cpu)); if (cpu == NULL) panic("OUT OF MEMORY!"); ol_cpu_init(cpu); ol_ps2_init_keyboard(); ol_apic_init(cpu); init_ioapic(); ol_pci_init(); debug("Little endian 0xf in net endian %x\n", htons(0xf)); #ifdef DBG #ifdef __IOAPIC_DBG ioapic_debug(); #endif #ifdef __MEMTEST ol_detach_all_devices(); /* free's al the pci devices */ #endif #ifdef __DBG_HEAP printf("Heap list:\n"); ol_dbg_heap(); #endif printf("\nSome (temp) debug info:\n"); printf("CPU vendor: %s\n", cpus->vendor); if(systables->magic == SYS_TABLE_MAGIC) { printf("RSDP ASCII signature: 0x%x%x\n", *(((uint32_t*) systables->rsdp->signature) + 1), *(((uint32_t*) systables->rsdp->signature))); printf("MP specification signature: 0x%x\n", systables->mp->signature); } #endif #ifdef PA_DBG addr_t p = (addr_t)page_alloc(); page_free((void*)p); printf("Allocated: %X\n", p); page_dump(); #endif #ifdef PA_DBG addr_t p = (addr_t)page_alloc(); page_free((void*)p); printf("Allocated: %X\n", p); page_dump(); #endif core_loop(); return 0; // To keep the compiler happy. }